将你的网站提交到搜索引擎

让搜索引擎收录你的网站

谷歌

百度

  • 近期百度关闭了资源提交的接口,但是还可以添加站点

必应

搜狗

操作比较简单,打开上面对应的网站,登录注册,然后验证自己的网站就可以


安装插件生成sitemap

如果你也是hexo搭建的博客网站,那么你可以使用一个插件来生成自己的sitemap,让搜索引擎更快的收录你的网站

安装插件

1
npm install hexo-generator-sitemap --save

配置

1
2
3
4
5
6
7
8
9
10
11
12
13
#生成站点地图
sitemap:
path:
- sitemap.xml
- sitemap.txt
template: template/sitemap.xml
template_txt: template/sitemap.txt
rel: false
tags: true
categories: true

#如果不想让某个页面生成sitemap,可以在对应md文件的头文件加入如下配置
sitemap: false

配置模板

在根目录创建template/sitemap.xml、template/sitemap.txt两个文件
将下面两个模板内容放入对应的文件中

  1. xml模板
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for post in posts %}
<url>
<loc>{{ post.permalink | uriencode }}</loc>
{% if post.updated %}
<lastmod>{{ post.updated | formatDate }}</lastmod>
{% elif post.date %}
<lastmod>{{ post.date | formatDate }}</lastmod>
{% endif %}
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>
{% endfor %}

<url>
<loc>{{ config.url | uriencode }}</loc>
<lastmod>{{ sNow | formatDate }}</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>

{% for tag in tags %}
<url>
<loc>{{ tag.permalink | uriencode }}</loc>
<lastmod>{{ sNow | formatDate }}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.2</priority>
</url>
{% endfor %}

{% for cat in categories %}
<url>
<loc>{{ cat.permalink | uriencode }}</loc>
<lastmod>{{ sNow | formatDate }}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.2</priority>
</url>
{% endfor %}
</urlset>

  1. txt模板
1
2
3
4
5
{% for post in posts %}{{ post.permalink | uriencode }}
{% endfor %}{{ config.url | uriencode }}
{% for tag in tags %}{{ tag.permalink | uriencode }}
{% endfor %}{% for cat in categories %}{{ cat.permalink | uriencode }}
{% endfor %}

访问

  • 你的网站域名/sitemap.xml
  • 你的网站域名/sitemap.txt