'meta description tag automatically
I am trying to add meta tag for description when it is missing in the posts. I want first 150 characters to be considered as description. I tried with multiple methods but does not work.
1st Method
<b:tag name='script' type='text/javascript'>
var msg = "<b:eval expr='snippet(data:post.body, {length: 150, links: false})'/>";
var metaDescription = document.head.children.description;
if (metaDescription == null) {
metaDescription = document.createElement('meta');
metaDescription.name = 'description';
document.head.append(metaDescription);
}
metaDescription.content = msg;
console.log(msg);
</b:tag>
2nd Method
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:blog.metaDescription == ""'>
<meta expr:content='data:post.longSnippet' name='description'/>
</b:if>
</b:if>
3rd Method
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:blog.metaDescription == ""'>
<meta expr:content='snippet(data:post.body, {length: 150, links: false})' name='description'/>
</b:if>
</b:if>
Solution 1:[1]
<b:eval expr='data:post.body snippet { length: 140 }'/>
example: https://skeleton001.blogspot.com/
source: https://geekthis.net/post/blogger-theme-data-tags-for-widgets/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | therkut |

