2

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

Pit
  • 21
  • 2

2 Answers2

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)'/>
  • So there is no way to use post.lables as meta name Keywords? i cant find the right way to do it... thanks anyways. – Pit May 08 '17 at 04:36
  • I think keywords are no longer important for google [read this](https://webmasters.googleblog.com/2016/11/saying-goodbye-to-content-keywords.html?hl=en) but if you want you can [use javascript to change meta tag](http://stackoverflow.com/questions/2568760/is-it-possible-to-use-javascript-to-change-the-meta-tags-of-the-page) after rendering blog posts widget. –  May 08 '17 at 17:13
0

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

Prayag Verma
  • 5,581
  • 3
  • 30
  • 56
  • Not Working i pased: in the post and it keeps displaying head keywords manually set – Pit May 09 '17 at 19:06
  • Could you share the blog URL where you tried to add this code? Also, you will have to paste the code as is (in the escaped form) otherwise it won't work. Also, paste inside the `` in the Blog `b:widget` tag to make it work – Prayag Verma May 10 '17 at 07:13
  • the blog is a draft template i am working on you can check it on : http://qh2n5.blogspot.com/2017/05/fffddfdfsdfsfs-ggfd-dfgfgd.html thanks for your time. – Pit May 11 '17 at 20:39