Use blogger post labels as meta data keywords

断了今生、忘了曾经 提交于 2019-12-14 01:26:43

问题


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


回答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)'/>



回答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



来源:https://stackoverflow.com/questions/43824583/use-blogger-post-labels-as-meta-data-keywords

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!