Sitemap 可方便网站管理员通知搜索引擎他们网站上有哪些可供抓取的网页。最简单的 Sitemap 形式,就是XML 文件,在其中列出网站中的网址以及关于每个网址的其他元数据(上次更新的时间、更改的频率以及相对于网站上其他网址的重要程度为何等),以便搜索引擎可以更加智能地抓取网站。
Google、雅虎、和微软都支持一个被称为xml网站地图(xml Sitemaps)的协议,而百度Sitemap是指百度支持的收录标准,在原有协议上做出了扩展。百度sitemap的作用是通过Sitemap告诉百度蜘蛛全面的站点链接,优化自己的网站。百度Sitemap分为三种格式:txt文本格式、xml格式、Sitemap索引格式。
启用sitemap功能
为了让博文被google或百度检索,需要使用hexo的sitemap功能。修改themes/next/_config.yml:
1 | menu: |
2、安装插件
切换到hexo根目录下,安装搜索引擎插件,插件根据自己的需要安装其中一个或者都安装:
1 | npm install hexo-generator-sitemap --save |
3、在博客目录的_config.yml中添加如下代码
1 | # 自动生成sitemap |
4、编译你的博客
如何此时你跟我一样使用的是next主题,直接执行如下命令即可访问站点地图:
1 | hexo g |
如果你在你的博客根目录的public下面发现生成了sitemap.xml以及baidusitemap.xml就表示成功了
5、谷歌检索
以GitHub Pages为例,新建的GitHub Pages是没有被谷歌检索的。在谷歌搜索栏中输入如下信息进行检索:
1 | site: xxx.github.io |
xxx为你的GitHub账号,如果没有被检索,不会显示hexo中的任何博文,如果有下面的步骤就可以省略了。
6、验证站点
需要谷歌账号,没有的可以申请一个。登录GoogleSearchConsole,点击立即使用,输入需要验证所有权的网站地址,例如本站地址
1 | </> |
对于hexo博客网站,最好使用 HTML标记 法验证网站所有权, 我发现next主题有更好的配置方式,千万不要采用修改head.swig文件的方法,不然在升级NexT版本时会遇到很多不必要的麻烦。修改themes/next/_config.yml文件:
1 | # Google Webmaster tools verification. |
然后生成静态文件并发布:
1 | hexo g |
回到谷歌搜索控制台继续进行验证,点击 完成。添加sitemap.xml
打开谷歌控制台选择上一步添加的网站->索引->站点地图,在添加新的站点地图中填入”sitemap.xml”即可,添加成功会在 已提交的站点地图 中显示,过一段时间在 概述 中会显示被索引的情况。
百度检索
- 添加站点
登录百度资源管理平台https://ziyuan.baidu.com/?castk=LTE%3D),依次点击 用户中心->站点管理->添加网站(网站会随时更新,路径可能不同,只要找到添加网站的位置就可以)。
(1)输入网址
1
如我的是:<https//qianyuniao.github.io>
(2)站点属性
最多可以选择三项,建议相关的都选上,提高曝光度
- (3)验证网站
NexT主题选择 HTML标签验证即可,复制标签中的content值,修改next配置文件_config.yml:
1 | # Baidu Webmaster tools verification. |
百度资源页面先不要关闭,执行下面的步骤之后再点击 完成验证。
发布并验证
hexo根目录下执行如下命令:
1
2hexo g
hexo d
回到百度资源网站,点击 完成验证。
参考资料
原文链接:https://blog.csdn.net/formemorywithyou/java/article/details/96478453
原文链接:https://blog.csdn.net/formemorywithyou/java/article/details/96478453
</div>
<hr/>
<div class="reprint" id="reprint-statement">
<div class="reprint__author">
<span class="reprint-meta" style="font-weight: bold;">
<i class="fas fa-user">
文章作者:
</i>
</span>
<span class="reprint-info">
<a href="/" rel="external nofollow noreferrer">qianyuniao</a>
</span>
</div>
<div class="reprint__type">
<span class="reprint-meta" style="font-weight: bold;">
<i class="fas fa-link">
文章链接:
</i>
</span>
<span class="reprint-info">
<a href="/posts/2020/04/22/qian-duan-kai-fa/wang-zhan-da-jian/hexo/hexo-bo-ke-zhan-dian-sitemap-de-shi-yong/">/posts/2020/04/22/qian-duan-kai-fa/wang-zhan-da-jian/hexo/hexo-bo-ke-zhan-dian-sitemap-de-shi-yong/</a>
</span>
</div>
<div class="reprint__notice">
<span class="reprint-meta" style="font-weight: bold;">
<i class="fas fa-copyright">
版权声明:
</i>
</span>
<span class="reprint-info">
本博客所有文章除特別声明外,均采用
<a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
许可协议。转载请注明来源
<a href="/" target="_blank">qianyuniao</a>
!
</span>
</div>
</div>
<script async defer>
document.addEventListener("copy", function (e) {
let toastHTML = '<span>复制成功,请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
M.toast({html: toastHTML})
});
function navToReprintStatement() {
$("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
}
</script>