自架部落格(2) Hexo 配置檔介紹

Hexo 配置檔(_config.yml)初次調整的說明和本部落格所調整的設置。

其實官網都寫得很清楚了,主要是記錄一下我調整的位置,後續如果有其他地方想再微調可以再看官方文件

Hexo 配置檔說明

注意:範例欄位是輸入的值,裡面有符號的話也要對,少了會報錯

Site

網站描述的設定

1
2
3
4
5
6
7
8
# Site
title: Hexo
subtitle: ''
description: ''
keywords:
author: John Doe
language: en
timezone: ''
名稱 描述 範例 我的調整 調整
title 標題(部落格名稱) My Blog My Blog
subtitle 副標題 這是我的部落格 這是我的部落格
description 描述 記錄各種點滴 記錄各種點滴
keywords 關鍵字,可多個,會在 <meta property="article:tag" content="你設定的keywords"> 顯示。多個時請直接使用,分隔 關鍵字1,關鍵字2,關鍵字3 blog,coding,programing
author 作者 Sam Sam
language 語言 zh-TW zh-TW
timezone 網站的時區,沒填預設是電腦的時區 ‘Asia/Taipei’ ‘’

URL

網址的設定,可想成網址路由的設定

1
2
3
4
5
6
7
8
# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: http://example.com
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks
名稱 描述 範例 我的調整 調整
url 這個網站的網址 https://example.com https://你的名字.github.io
permalink 文章連結的格式,必須包在:/之間,預設https://你的網址/2022/06/26/文章標題 :year/:month/:day/:title/ :title/
permalink_defaults permalink各區段的預設值
permalink_defaults.trailing_index 是否在URL的結尾保留index.html true false
permalink_defaults.trailing_html 是否在URL的結尾保留.html ,對index.html無效 true false

Extensions

擴充套件

1
2
3
4
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape
名稱 描述 範例 我的調整 調整
theme 主題,設為false代表關閉 landscape next

Deployment

部署設定

1
2
3
4
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: ''

之後會部署到GitHub Pages,所以先來調整成git版所需的參數

1
2
3
4
5
6
7
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: 'git'
repo: <repository url> # https://bitbucket.org/JohnSmith/johnsmith.bitbucket.io
branch: [branch]
message: [message]
名稱 描述 範例 我的調整 調整
type 類型。有很多種,可以看文件 ‘git’ ‘git’
repo repository的網址 https://bitbucket.org/JohnSmith/johnsmith.bitbucket.io https://github.com/GitHub的名稱/GitHub的名稱.github.io.git
branch 分支名稱 gh-pages master
message Commit的訊息,不填預設Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }} init commit

參考