Hexo -2- 站點信息配置

這是我參與8月更文挑戰的第三天,Hexo框架中配置文件內容描述與示例。html

_config.yml - 站點配置文件

在各類Hexo相關教程中頻繁出現站點配置文件,指的是Hexo根目錄中的文件_config.ymlgit

具體內容也能夠參考官方文檔github

  • 注意:配置過程當中每一項的英文冒號後須要一個空格

Site - 網站

參數 描述
title 網站標題
subtitle 網站副標題
description 網站描述
keywords 網站的關鍵詞。使用半角逗號 , 分隔多個關鍵詞。
author 您的名字
language 網站使用的語言 (初始建議此處設置爲zh-Hans,便於後續穩定翻譯)
timezone 網站時區。Hexo 默認使用您電腦的時區。請參考 時區列表 進行設置,如 America/New_York, Japan, 和 UTC 。通常的,對於中國大陸地區能夠使用 Asia/Shanghai
  • 這部分是咱們剛剛建站時須要設置的部分,建議修改。以個人站點配置爲例:
# Site
title: 又見蒼嵐
subtitle: 'www.zywvvd.com'
description: 'Stay hungury ! Stay foolish !'
keywords: '人工智能, 深度學習, 我的博客'
author: Yiwei Zhang
language: zh-Hans
timezone: Asia/Shanghai
複製代碼

URL - 網址

參數 描述 默認值
url 網址
root 網站根目錄
permalink 文章的 永久連接 格式 :year/:month/:day/:title/
permalink_defaults 永久連接中各部分的默認值
pretty_urls 改寫 permalink 的值來美化 URL
pretty_urls.trailing_index 是否在永久連接中保留尾部的 index.html,設置爲 false 時去除 true
pretty_urls.trailing_html 是否在永久連接中保留尾部的 .html, 設置爲 false 時去除 (對尾部的 index.html無效)
  • url 和 root 須要關聯到掛載的服務器目錄

修改站點配置文件,填入網址設置:服務器

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://github.com/<Github帳號>/<Github帳號>.github.io
root: /<Github帳號>.github.io/
複製代碼
  • 修改文章永久連接

默認文章路徑相似: www.zywvvd.com/2020/02/27/…markdown

這是由於文章連接配置permalink值默認爲:year/:month/:day/:title/hexo

不喜歡此種形式連接的同窗能夠自定義修改,例如:app

permalink: :category/:title/
複製代碼

能夠使用以下變量和 Front-matter 中的全部屬性。框架

變量 描述
:year 文章的發表年份(4 位數)
:month 文章的發表月份(2 位數)
:i_month 文章的發表月份(去掉開頭的零)
:day 文章的發表日期 (2 位數)
:i_day 文章的發表日期(去掉開頭的零)
:hour 文章發表時的小時 (2 位數)
:minute 文章發表時的分鐘 (2 位數)
:title 文件名稱
:post_title 文章標題
:id 文章 ID (not persistent across cache reset)
:category 分類。若是文章沒有分類,則是 default_category 配置信息。

Directory - 目錄

參數 描述 默認值
source_dir 資源文件夾,這個文件夾用來存放內容。 source
public_dir 公共文件夾,這個文件夾用於存放生成的站點文件。 public
tag_dir 標籤文件夾 tags
archive_dir 歸檔文件夾 archives
category_dir 分類文件夾 categories
code_dir Include code 文件夾,source_dir 下的子目錄 downloads/code
i18n_dir 國際化(i18n)文件夾 :lang
skip_render 跳過指定文件的渲染。匹配到的文件將會被不作改動地複製到 public 目錄中。您可以使用 glob 表達式來匹配路徑。

Writing - 文章

參數 描述 默認值
new_post_name 新文章的文件名稱 :title.md
default_layout 預設佈局 post
auto_spacing 在中文和英文之間加入空格 false
titlecase 把標題轉換爲 title case false
external_link 在新標籤中打開連接 true
external_link.enable 在新標籤中打開連接 true
external_link.field 對整個網站(site)生效或僅對文章(post)生效 site
external_link.exclude 須要排除的域名。主域名和子域名如 www 需分別配置 []
filename_case 把文件名稱轉換爲 (1) 小寫或 (2) 大寫 0
render_drafts 顯示草稿 false
post_asset_folder 啓動 Asset 文件夾 (建議設置爲 True ) false
relative_link 把連接改成與根目錄的相對位址 false
future 顯示將來的文章 true
highlight 代碼塊的設置
highlight.enable 開啓代碼塊高亮 true
highlight.auto_detect 若是未指定語言,則啓用自動檢測 false
highlight.line_number 顯示行數 Enabling this option will also enable wrap option true
highlight.tab_replace 用 n 個空格替換 tabs;若是值爲空,則不會替換 tabs ''
highlight.wrap Wrap the code block in `` true
highlight.hljs Use the hljs-* prefix for CSS classes false
  • post_asset_folder修改成true,這樣新建文章時會建立同名文件夾,便於後期博客圖片等資源管理

Category & Tag - 分類 & 標籤

參數 描述 默認值
default_category 默認分類 uncategorized
category_map 分類別名
tag_map 標籤別名

Date / Time format - 日期 / 時間格式

Hexo 使用 Moment.js 來解析和顯示時間。oop

參數 描述 默認值
date_format 日期格式 YYYY-MM-DD
time_format 時間格式 HH:mm:ss
use_date_for_updated 啓用之後,若是 Front Matter 中沒有指定 updatedpost.updated 將會使用 date 的值而不是文件的建立時間。在 Git 工做流中這個選項會頗有用 true

Pagination - 分頁

參數 描述 默認值
per_page 每頁顯示的文章量 (0 = 關閉分頁功能) 10
pagination_dir 分頁目錄 page

Extensions - 擴展

參數 描述
theme 當前主題名稱。值爲false時禁用主題
theme_config 主題的配置文件。在這裏放置的配置會覆蓋主題目錄下的 _config.yml 中的配置
deploy 部署部分的設置
meta_generator Meta generator 標籤。 值爲 false 時 Hexo 不會在頭部插入該標籤
  • 更換主題時改變theme的值爲主題名稱

Include / Exclude file(s) - 包括或不包括目錄和文件

在 Hexo 配置文件中,經過設置 include/exclude 可讓 Hexo 進行處理或忽略某些目錄和文件夾。你能夠使用 glob 表達式 對目錄和文件進行匹配。佈局

include and exclude options only apply to the source/ folder, whereas ignore option applies to all folders.

參數 描述
include Hexo 默認會忽略隱藏文件和文件夾(包括名稱如下劃線和 . 開頭的文件和文件夾,Hexo 的 _posts_data 等目錄除外)。經過設置此字段將使 Hexo 處理他們並將它們複製到 source 目錄下。
exclude Hexo 會忽略這些文件和目錄
ignore Ignore files/folders
相關文章
相關標籤/搜索