將網站鏈接提交到百度
百度搜索引擎提交入口
有三種驗證方式,我選擇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.xml
和baidusitemap.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') }} » </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
即可。