shenliyang / hexo-theme-snippet

Snippet 简洁而不简单,也许是一款你寻找已久的hexo主题
https://snippet.shenliyang.com/
MIT License
1.09k stars 208 forks source link

SEO问题 #98

Closed eacdy closed 5 years ago

eacdy commented 5 years ago

如题,目前不管是首页,还是内页,网页的title、description等描述都是一样的。建议使用内页的title和summary作为网页的title、description。

我在这里做了修正,https://github.com/itmuch/hexo-theme-itmuch 如有需要可以提交PR

shenliyang commented 5 years ago

:flushed: 好像早些时间已经修复该问题了,现在还存在吗?主题链接

eacdy commented 5 years ago

貌似解决了,哈哈。

eacdy commented 5 years ago

image

经测试,问题没有解决。

建议将layout/_partial/_head-sections/seo.ejs 改为如下代码:

<!--SEO-->
<% if(page.keywords){ %>
    <meta name="keywords" content="{{ page.keywords }}" />
<% } else if(page.tags && page.tags.length) { %>
    <meta name="keywords" content="<% page.tags.forEach(function (item) {%><%- item.name%>,<%})%>" />
<% } else{ %>
    <meta name="keywords" content="<%= config.keywords%>" />
<%}%>
<% if(page.content){ %>
    <meta name="description" content="<%- truncate(strip_html(page.content), {length: 150, omission: '...'}) %>" />
<% } else{ %>
    <meta name="description" content="<%= config.description%>" />
<%}%>
<% var robotMeta = theme.robot||'all'; %>
<meta name="robots" content="<%= robotMeta%>" />
<meta name="google" content="<%= robotMeta%>" />
<meta name="googlebot" content="<%= robotMeta%>" />
<meta name="verify" content="<%= robotMeta%>" />