設定檔
Qiandu 從 Hugo 網站根目錄下的 hugo.yaml 讀取設定。
在設定檔中,您可以設定網站的所有選項。
你可以在 exampleSite/hugo.yaml 中找到此網站的設定檔作為開始。
導覽列
選單
右上角的選單在設定檔的 menu.main 中設定:
menu:
main:
- name: Documentation
pageRef: /docs
weight: 1
- name: Blog
pageRef: /blog
weight: 2
- name: About
pageRef: /about
weight: 3
- name: Search
weight: 4
params:
type: search
- name: GitHub
weight: 5
url: ""
params:
icon: github有幾種不同類型的選單項目:
- Link to a page in the site with
pageRef- name: Documentation pageRef: /docs - Link to an external URL with
url- name: GitHub url: "https://github.com" - Search bar with
type: search- name: Search params: type: search - Icon
- name: GitHub params: icon: github
這些選單項目可以透過設定 weight 進行排序。
側邊欄
主側邊欄
主側邊欄是自動從 content 目錄結構產生的。
有關更多詳細信息,請轉至 目錄結構。
額外鏈接
側邊欄的額外連結在設定檔的 menu.sidebar 部分中設定:
menu:
sidebar:
- name: More
params:
type: separator
weight: 1
- name: "About"
pageRef: "/about"
weight: 2
- name: "Docs ↗"
url: "https://gohugo.io/name/"
weight: 3右側邊欄
目錄
目錄是根據內容檔案中的標題自動產生的,可以在 front matter 設定 toc:false 來停用它。
---
title: Configuration
toc: false
---編輯此頁鏈接
要配置編輯此頁鏈接,我們可以在設定檔中設定 params.editURL.base:
params:
editURL:
base: "https://github.com/your-username/your-repo/edit/main"將為每個頁面自動產生編輯連結。
如需為特定頁面設定編輯鏈接,可以在頁面的 front matter 中設定 editURL:
---
title: Configuration
editURL: "https://example.com/edit/this/page"
---Footer
版權聲明
如需修改網站頁腳中顯示的版權文本,您需要建立一個名為「i18n/en.yaml」的檔案。 在此文件中,填寫新的版權文本,像這樣:
copyright: "© 2024 Qiandu.org"你可以在 GitHub 儲存庫中找到範例 i18n/en.yaml 檔案。另外,你可以在版權文字中使用 Markdown 格式。
其他
Favicon
如需自訂favicon,請將圖示檔案放在static 資料夾下以覆蓋[主題中的預設favicon](https://github .com/imfing/hextra/tree/main/static):
- android-chrome-192x192.png
- android-chrome-512x512.png
- apple-touch-icon.png
- favicon-16x16.png
- favicon-32x32.png
- favicon-dark.svg
- favicon.ico
- favicon.svg
- site.webmanifest
在您的專案中包含 favicon.ico 和 favicon.svg 文件,以確保網站的網站圖示正確顯示。
雖然favicon.ico 通常適用於較舊的瀏覽器,但favicon.svg 受到現代瀏覽器的支持,所以更現代的做法是添加favicon-dark.svg 以便在黑暗模式下提供較好的體驗體驗。
請隨意使用 favicon.io 或 favycon 等工具來產生這些圖示。
顏色主題配置
使用theme設定來配置預設主題模式和切換按鈕,讓訪客在淺色或深色模式之間切換。
params:
theme:
# light | dark | system
default: system
displayToggle: truetheme.default 的可選項:
light- 僅使用淺色模式dark- 僅使用神色模式system- 跟隨系統
theme.displayToggle 控制顯示用於更改主題的切換按鈕。
設定為“true”時,訪客可以在淺色或深色模式之間切換,覆蓋預設值。
頁寬
頁面的寬度可以透過設定檔中的params.page.width參數來調整:
params:
page:
# full (100%), wide (90rem), normal (1280px)
width: wide有三个可选项:full, wide, and normal. 默认的页宽模式是 normal.
同样的,导航栏和 footer 的宽度也可通过 params.navbar.width 和 params.footer.width 调整。
搜索
默认情况下启用由 FlexSearch 提供全文搜索。
要自定义搜索索引,请在配置文件中设置 params.search.flexsearch.index :
params:
# Search
search:
enable: true
type: flexsearch
flexsearch:
# index page by: content | summary | heading | title
index: contentflexsearch.index 的可选项:
content- 全内容搜索summary- 概述 Hugo Content Summariesheading- 一级和二级标题title- 仅搜索标题
要自定义检索分词,请在配置文件中设置params.search.flexsearch.tokenize:
params:
# ...
flexsearch:
# full | forward | reverse | strict
tokenize: forwardflexsearch.tokenize的可选项:
strict- 严格单词匹配forward- 单词前缀匹配reverse- 单词前后缀匹配full- 单词子串匹配。
在默认的分词逻辑下,中文一句话就是一个“单词”
要从搜索索引中排除页面,更改 front matter 中的 excludeSearch: true:
---
title: Configuration
excludeSearch: true
---Google Analytics
要启用 Google Analytics,设置 services.googleAnalytics.ID:
services:
googleAnalytics:
ID: G-MEASUREMENT_ID