Reputation: 113
I'm using blogger, and I want to use different <title>
tags depending on the post labels. For example, if a post has the label: "SOMELABEL1", it will show <title>Title1 - Wbsitename</title>
, and if the post has the label: "SOMELABEL2", it will show <title>2222 - Webitename</title>
.
I have tried to use the following code (which is working on the middle of the page - in the body), but not in the head start:
<b:if cond='data:post.labels any (l => l.name in "LABEL1")'>
<title>1111 - Webitename</title>.
<b:else/>
<title>2222 - Webitename</title>.
</b:if>
Please help.
Upvotes: 3
Views: 2331
Reputation:
You can not check data:post.labels
outside the Blog widget but the good news is that you can use your code inside Blog widget to change the page title via JavaScript.
<b:if cond='data:post.labels any (label => label.name == "LABEL1")'>
<script type="text/javascript">
document.title="1111 - Webitename";
</script>
<b:else/>
<script type="text/javascript">
document.title="2222 - Webitename";
</script>
</b:if>
But changing the page title via JavaScript won't help SEO because some web crawlers do not support JavaScript. (Google's does)
Upvotes: 4