skip to Main Content

I am starting to make blogger templates from scratch and i am making a research about best SEO metadata for each post. I think the most logical way to use meta name=keywords is to use post labels as keywords but i don’t understand why i cant retrieve the data and display it in the meta section as i can with the data from description. for expample:

    <b:if cond='data:blog.pageType != &quot;error_page&quot;'>
<meta expr:content='data:blog.metaDescription' name='description'/>
</b:if>

puts the data comming from blog.metaDescription as content for meta description, but when i want to use:

<meta expr:content='data:post.labels.name' name='keywords' />

Which should be the data retrieved from the post labels, it doesn’t display anything… as if there is no such data… i wonder why please help … i am going mad with this, i tried a lot of stuff and i cant accomplish to use post labels as meta keywords.

Best Regards

2

Answers


  1. You can only retrieve post labels inside Blog Posts widget <b:widget type='Blog' ...> and that is through a loop tag like the following

    <b:loop values='data:post.labels' var='label'>
        <data:label.name/>
    </b:loop>
    

    Or you can also use a lambda expression

    <b:eval expr='data:post.labels map (label => label.name)'/>
    
    Login or Signup to reply.
  2. The following code should work –

    &lt;meta content=&quot;<b:loop values='data:post.labels' var='label'><data:label.name/><b:if cond='not data:label.isLast'>,</b:if></b:loop>&quot; name='keywords'/&gt;
    

    But the shortcoming being that it will only work in the post area (present inside the <body> tag) and not in the <head> region

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search