Hexo Tutorial
Hexo Tutorial
blog
Basic
建立
1
2
3
4hexo init name //初始化新的 Hexo,會在當前路徑建立一個叫 name 的資料夾,資料夾名稱可以隨意取,例如「myblog」,那麼指令就是 hexo init myblog
cd name //進入您剛剛建立的 name 資料夾當中,cd 是 change directory 的意思
npm install //安裝 Hexo
npm install hexo-deployer-git --save //安裝 git 部署套件setting
1
2
3
4
5
6
7title: 我的部落格 //輸入部落格標題
subtitle: 一個抒發本人心情的地方 //輸入副標題
description: //輸入網站描述
keywords: //輸入網站關鍵字(以逗號隔開),方便 SEO
author: 王小明 //輸入姓名或暱稱
language: zh-TW //輸入您所使用的語言
timezone: //留空以使用系統時間new post
1
2hexo new [layout] title
[layout]: post, page, draftdeploy
1
2
3
4deploy:
type: git
repo: https://github.com/username/username.github.io.git
branch: master1
2
3hexo cl //清除之前建立的靜態檔案,也可以輸入 hexo clean
hexo g //建立靜態檔案,也可以輸入 hexo generate
hexo d //部署至 Github Pages,也可以輸入 hexo deploy
others
read more function
- native in next theme
1
2
3auto_excerpt:
enable: true
length: 150- it dose not work
- it dose not work
- hexo-excerpt
- hexo-excerpt - github
1
2
3
4
5excerpt:
depth: 10
excerpt_excludes: \[\]
more_excludes: \[\]
hideWholePostExcerpts: true
- hexo-excerpt - github
- manually add in md
1
<!--more-->
- native in next theme
change Favicon in next
Go the blog root, under the
source
folder, create a folder namedimages
. Copy the extracted files to this folder. Then edit the theme NexT configuration file (i.e.,theme/next-new/_config.yml
). Find the part about favicon and use the following settings,1
2
3
4
5
6
7favicon:
small: images/favicon-16x16.png
medium: images/favicon-32x32.png
apple_touch_icon: images/apple-icon-180x180.png
safari_pinned_tab:
android_manifest: images/manifest.json
ms_browserconfig: images/browserconfig.xmlPlugin
hexo count time
- hexo-symbols-count-time - github
1
2
3
4
5
6
7
8
9symbols_count_time:
symbols: true
time: true
total_symbols: true
total_time: true
exclude_codeblock: false
awl: 4
wpm: 275
suffix: "mins."
- hexo-symbols-count-time - github
hexo sitemap
You can configure this plugin in
_config.yml
.1
2
3
4
5
6sitemap:
path: sitemap.xml
template: ./sitemap_template.xml
rel: false
tags: true
categories: truepath - Sitemap path. (Default: sitemap.xml)
template - Custom template path. This file will be used to generate sitemap.xml (See default template)
rel - Add
rel-sitemap
to the site’s header. (Default:false
)tags - Add site’s tags
categories - Add site’s categories
set up sitemap
go to Google Search Console
有多種驗證方式
- 以 hexo 來說,比較方便是直接用 google analysis
- 先到 gooogle analysis 建立一個專案
- 到
_config.yml
中1
2
3
4
5
6# Google Analytics
google_analytics:
tracking_id: {add_your_track_id}
# By default, NexT will load an external gtag.js script on your site.
# If you only need the pageview feature, set the following option to true to get a better performance.
only_pageview: false
提交 sitemape.xml
count viewer
Trouble shoot
TypeError: Cannot read property ‘enable’ of undefined
- 因為
themes/next/_config.yml
中update_at
的設定不能為 false,如果不要設定要留空
- 因為
visit counter not works
在沒有設定好時就開始測試與設定會出錯,因為根據程式碼所寫的,有三個條件要滿足才會加一
- CONFIG.hostname === location.hostname
- 在 localhost 的狀況下會無效
- localStorage.getItem(title)
- 他會在 Local storage 中暫存 title ,代表已經看過就不會更新
- !d.exists
- CONFIG.hostname === location.hostname