快轉到主要內容

開發設定

查看原始碼編輯此頁 (外部連結)

本文介紹 Hugo 開發相關設定。

編輯器設定 此標題的連結

Formatter 設定 此標題的連結

HTML 此標題的連結

可以使用 prettier 插件以格式化 HTML + go-template。

npm install --save-dev prettier prettier-plugin-go-template
.prettierrc
{
  "plugins": ["prettier-plugin-go-template"],
  "overrides": [
    {
      "files": ["*.html"],
      "options": {
        "parser": "go-template"
      }
    }
  ]
}

並且使用 prettier --write --list-different FILE 格式化。

也可以使用 Hugo 官方的 gotmplfmt (外部連結),和 prettier 相比最大的差異為 gotmplfmt 不支援沒有任何設定,不支援 style 和 script 標籤,而且不是 npm 生態系。

Markdown 此標題的連結

rumdl (外部連結) 是 Markdown LSP 而不只是 formatter,並且支援 Hugo 特殊用法,比如 shortcode, Markdown attributes (外部連結), custom root (外部連結) 等等。

無障礙設定

字體大小