I'd like to add description meta in my blog page for SEO:
<meta name="description" content="作为Node.js开发者,有必要全面了解一下Node命令的所有选项,这样在关键时刻才能得心应手。" >
I add following code in head.ejs
<meta name="description" content="<%= strip_html(page.excerpt) %>" >
But the result is unreadable:
<meta name="description" content="&#x8BD1;&#x8005;&#x6309;: &#x4F5C;&#x4E3A;Node.js&#x5F00;&#x53D1;&#x8005;&#xFF0C;&#x6709;&#x5FC5;&#x8981;&#x5168;&#x9762;&#x4E86;&#x89E3;&#x4E00;&#x4E0B;Node&#x547D;&#x4EE4;&#x7684;&#x6240;&#x6709;&#x9009;&#x9879;&#xFF0C;&#x8FD9;&#x6837;&#x5728;&#x5173;&#x952E;&#x65F6;&#x523B;&#x624D;&#x80FD;&#x5F97;&#x5FC3;&#x5E94;&#x624B;&#x3002;" >
It seems not right because search engine may not understand it.
I tried to decode the content using http://www.cafewebmaster.com/online_tools/utf_decode. So the messy code is called "HTML entities decode".
How can I decode them in head.ejs to generate correct html?
Hey, there is how hexo-theme-material make it:
https://github.com/viosey/hexo-theme-material/commit/a4f6eabde6ad4e7eaae4cae9f5876e5ee9f7bd97
I use the replace to avoid the messy code.
There is a demo: https://blog.nfz.moe
@neoFelhz THX. But it does not work...
Use open_graph helper.
This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Hey, there is how hexo-theme-material make it:
https://github.com/viosey/hexo-theme-material/commit/a4f6eabde6ad4e7eaae4cae9f5876e5ee9f7bd97
I use the replace to avoid the messy code.
There is a demo: https://blog.nfz.moe