今天想让google能搜索到自己的博客,网上也有很多的教程,这里自己做一个记录,其中在google提交站点地图的时候,全部报错,下面记录下修改过程。

1. 打开Google搜索引擎提交入口

链接在此

2. 登录Google账号后填写自己的网址,然后进入下载验证文件界面,此时下载HTML验证文件,将此文件放在source目录下,对该文件做个小改动,添加前两行

layout: false
---
google-site-verification: google91f0f9be9565e882.html

###然后部署

1
2
3
hexo c
hexo g
hexo d

3.浏览器访问

https://zllrunning.github.io/google91f0f9be9565e882.html

###可以看到一串字符,说明完成

4.安装插件生成sitemap

npm install hexo-generator-sitemap --save

5. 编辑博客_config.yml文件,添加

# Sitemap-google
sitemap:
        path: sitemap.xml

注意此时需要检查一个地方是否正确,将yoursite.com更改为自己的,我在这之前没改yoursite.com,在第六步的时候提交出现一系列错误(错误为:查看了sitemap.xml文件后发现,全是youtise.com).

###有问题的sitemap.xml

错误如图

正常的sitemap.xml

正常的如图

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com

###未更改之前如上所示,更改后如下所示

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://zllrunning.github.io

###然后部署

1
2
3
hexo c
hexo g
hexo d

6.提交站点地图

  • 进入search console,左侧有选项–>抓取–>站点地图
  • 右上角添加sitemap.xml,提交,OK。
    提交