23.04.06_blog能被搜索到

发布时间 2023-04-06 21:38:24作者: Lantary

博客优化内容

对于刚建立的博客来说,谷歌往往不能或者不会收录你的博客,为了使自己的博客可以被谷歌所检索到。我们需要主动向谷歌提供网址信息。

提交到百度搜索

访问百度搜索资源平台官网,注册或者登陆百度账号,依次选择 用户中心 --> 站点管理 输入你的网站,协议头推荐是https协议的,如果你没有https协议后面可能会出现报错,因为hexo会强制把你的链接转为https协议

image-20230406184459593

下载验证文件,放到blog的 source 目录中,设置下根目录的配置文件 _config.yml 防止这个html被 hexo g 命令重新渲染。

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render: 
    - <你的百度验证html名>.html

然后 hexo clean; hexo g; hexo d ,完成验证。

主动提交

在博客根目录安装插件 npm install hexo-baidu-url-submit --save,然后在根目录 _config.yml 文件里写入以下配置:

baidu_url_submit:
  count: 99              # 提交最新的多少个链接
  host: lantary.cn    	 # 在百度站长平台中添加的域名
  token: [your_token]    # 秘钥
  path: baidu_urls.txt   # 文本文档的地址, 新链接会保存在此文本文档里

token在 普通收录 -> API提交 中能看到

image-20230406191810013

同时在 URL 出写上你的站点

# URL
url: https://lantary.cn
permalink: :url_dir/:url_name.html
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

最后,加入新的deployer:

deploy:
- type: git
  repository: git@39.107.253.31:/home/git/blog.git
  branch: master
- type: baidu_url_submitter 		# 新加的推送

最后运行 hexo clean; hexo g; hexo d,显示

{"remain":2965,"success":33}

说明成功推送33个链接,remain是当天剩余可推送的条数

sitemap提交

推荐sitemap提交和主动提交一起部署,先安装一下插件

npm install hexo-generator-sitemap --save     
npm install hexo-generator-baidu-sitemap --save

然后使用命令 hexo g; hexo d 就在首页生成了sitemap.xml文件,其中,sitemap.xml是通用的站点地图,而baidusitemap.xml是百度专用的站点地图,我的npm在安装baidu的站点地图的时候出了一点bug,就不管了,反正每次部署都会进行主动推送。

提交的google搜索

打开Google搜索管理后台登录后添加你的网址

image-20230406210813377

我选择的是网址模式,输入我的域名https://lantary.cn

同样的也选择html文件验证,下载html验证文件后置于source文件,然后配置配置文件使hexo g 跳过对该文件的渲染

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render: 
    - <你的百度html验证文件>.html
    - <你的谷歌html验证文件>.html

验证所有权后,进入提交网址过程。

如果你刚刚在配置百度搜索的时候已经安装了站点地图插件这个时候直接 hexo d 然后将你站点的sitemap.xml输入到谷歌搜索的站点地图中

image-20230406211948400

如果你没有安装插件则

npm install hexo-generator-sitemap --save  
hexo g;hexo d

然后再提交站点地图

提交到bing搜索

点击到bing搜索管理后台登录后添加你的网址

image-20230406210733486

然后选择直接导入就行,如果你的网络有问题不能导入,那么手动添加网址,操作流程跟谷歌搜索的方法一模一样这里不做赘述了。

参考链接

[1] 解决验证问题

[2] 提交sitemap

[3] 提交百度搜索

[4] 跳过hexo渲染