Github Page Setup (2) 加入進階功能 + SEO

瀏覽人次統計

● 修改 theme/next/_config.yml :

busuanzi_count:
  enable: true
  total_visitors: true
  total_visitors_icon: user
  total_views: true
  total_views_icon: eye
  post_views: true
  post_views_icon: eye

建立留言板

● 使用Disqus :

● 註冊一組帳密,在下一步中選擇 “I want to install Disqus on my site”

● Website Name 中填入自己的網站名

● 最後修改 theme/next/_config.yml:

disqus:
enable: true
shortname: <your-website-name>
count: true

RSS訂閱

● 安裝套件

npm install hexo-generator-feed

● 修改 theme/next/_config.yml,加入:

feed:
type: atom
path: atom.xml
limit: 20  

文章預覽斷點

● 利用做斷點

預覽可見
<!--more-->
預覽不可見

設定背景圖片

● 把想當背景的照片放入 blog/themes/next/source/images

● 接著修改 blog/themes/next/source/css/_custom/custom.sty , 加入

body { background:url(/images/背景圖.jpg);}

● 我自己是使用 unsplash 這個網站的背景,該網站有更多背景的設置樣式。

● 一樣修改 blog/themes/next/source/css/_custom/custom.sty,改成

body {
    background:url(https://source.unsplash.com/1600x900/?water);
    background-repeat: no-repeat;
    background-attachment:fixed;
    background-position:80% 80%; 
}

加入Google Analytics

● 先到 Google Analytics 首頁登或建立帳戶,新增一個資源後填入帳號名稱、網站名稱和網址,即可按下取得追蹤編號。

● 修改 theme/next/_config.yml:

google_analytics: your-analytics-id

加入sitemap

● 安裝插件

npm install hexo-generator-sitemap --save

● 修改 theme/next/_config.yml,加入:

sitemap:
  path: sitemap.xml

● 修改 theme/next/_config.yml:

url: your-website-name

hexo generate 後,就能在 blog/public 中生成sitemap.xml,之後會提交給 Google

加入robots.txt

● 在blog/source中新建文件robots.txt


User-agent: *
Allow: /
Allow: /archives/
Allow: /categories/
Allow: /tags/

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


Sitemap: http://your-website-name/sitemap.xml

● 最後再 hexo generate hexo deploy


注册Google Search Console

● 在Google Search Console 中,新增你的網址。

● 測試 robots.txt

● 提交 sitemap.xml

● Google 抓取方式 ,將首頁跟想要曝光的網誌輸入至抓取,並提交至索引。

● 輸入 site:your-website-name 就可以 Google 到我們的網站了

0%