hexo站点地图

将网站链接提交到百度

百度搜索引擎提交入口 
有三种验证方式,我选择Html标签验证,在themes\next\layout\_partials\head.swing中添加验证代码:

<meta name="baidu-site-verification" content="s8Pe1TBqyy" />

然后点击完成验证,通过即可。同理将站点链接也提交到Google和搜狗,此处不表。

给站点添加sitemap

1、 Hexo安装sitemap

npm install hexo-generator-sitemap --save #sitemap.xml适合提交给谷歌搜素引擎
npm install hexo-generator-baidu-sitemap --save #baidusitemap.xml适合提交百度搜索引擎

 

2、 在站点配置文件_config.yml中添加以下代码

# 自动生成sitemap
sitemap:
path: sitemap.xml
baidusitemap:
path: baidusitemap.xml

 

3、 修改站点配置文件_config.yml

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

 

4、 Hexo编译

hexo clean
hexo g

 

会/public目录下生成sitemap.xmlbaidusitemap.xml,这就是你的站点地图。

5、 提交sitemap到站长平台

百度站长平台sitemap提交是邀请制的,并没有对所有站长开放,只有网站到一定等级百度才会在你后台开放提交sitemap的入口。

添加蜘蛛协议robots.txt

1、 新建robots.txt文件,添加以下文件内容,把robots.txt放在hexo站点的source文件下。

# hexo robots.txt
User-agent: *
Allow: /
Allow: /archives/

Disallow: /vendors/
Disallow: /js/
Disallow: /css/
Disallow: /fonts/
Disallow: /vendors/
Disallow: /fancybox/

Sitemap: http://www.zaoanx.com/sitemap.xml
Sitemap: http://www.zaoanx.com/baidusitemap.xml

 

2、 在百度站长平台监测并更新Robots 
提示检测到您更新了Robots文件即成功。

给出站链接添加 “nofollow” 标签

nofollow标签是由谷歌领头创新的一个“反垃圾链接”的标签,并被百度、yahoo等各大搜索引擎广泛支持,引用nofollow标签的目的是:用于指示搜索引擎不要追踪(即抓取)网页上的带有nofollow属性的任何出站链接,以减少垃圾链接的分散网站权重。

以hexo的NexT主题为例,需要修改两处 
1、 找到footer.swig,路径在your-hexo-site\themes\next\layout\_partials,将下面代码

{{ __('footer.powered', '<a class="theme-link" href="http://hexo.io">Hexo</a>') }}
  • 1

改成

{{ __('footer.powered', '<a class="theme-link" href="http://hexo.io" rel="external nofollow">Hexo</a>') }}
  • 1

将下面代码

<a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
  • 1

改成

<a class="theme-link" href="https://github.com/iissnan/hexo-theme-next" rel="external nofollow">
  • 1

2、 修改sidebar.swig文件,路径在your-hexo-site\themes\next\layout_macro,将下面代码

<a href="{{ link }}" target="_blank">{{ name }}</a>
  • 1

改成

<a href="{{ link }}" target="_blank" rel="external nofollow">{{ name }}</a>
  • 1

将下面代码

<a href="http://creativecommons.org/licenses/{{ theme.creative_commons }}/4.0" class="cc-opacity" target="_blank">
  • 1

改成

<a href="http://creativecommons.org/licenses/{{ theme.creative_commons }}/4.0" class="cc-opacity" target="_blank" rel="external nofollow">
  • 1

可以使用chinaz站长工具进行各项检测。

keywords 和 description

\scaffolds\post.md中添加如下代码,用于生成的文章中添加关键字和描述。

keywords: 
description: 
  • 1
  • 2

\themes\next\layout\_partials\head.swig有如下代码,用于生成文章的keywords。暂时还没找到生成description的位置。

{% if page.keywords %}
  <meta name="keywords" content="{{ page.keywords }}" />
{% elif page.tags and page.tags.length %}
  <meta name="keywords" content="{% for tag in page.tags %}{{ tag.name }},{% endfor %}" />
{% elif theme.keywords %}
  <meta name="keywords" content="{{ theme.keywords }}" />
{% endif %}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

然后在\themes\next\layout\_macro\post.swig中找到这个位置:

{% if post.description %}
  • 1

将以下代码去掉:

{% if post.description %}
  {{ post.description }}
  <div class="post-more-link text-center">
    <a class="btn" href="{{ url_for(post.path) }}">
      {{ __('post.read_more') }} &raquo;
    </a>
  </div>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

否则首页的文章摘要就会变成文章的description

首页title的优化

更改index.swig文件,文件路径是your-hexo-site\themes\next\layout,将下面代码

{% block title %} {{ config.title }} {% endblock %}
  • 1

改成

{% block title %} {{ config.title }} - {{ theme.description }} {% endblock %}
  • 1

这时候你的首页标题会更符合网站名称 - 网站描述这习惯。

修改文章链接

HEXO默认的文章链接形式为domain/year/month/day/postname,默认就是一个四级url,并且可能造成url过长,对搜索引擎是十分不友好的,我们可以改成 domain/postname 的形式。编辑站点_config.yml文件,修改其中的permalink字段改为permalink: :title.html即可。

posted @ 2018-03-02 14:46  brady-wang  阅读(1675)  评论(0编辑  收藏  举报