ref: https://gohugo.io/getting-started/configuration/#publishdir
在 Hugo 中,默認情況下,生成的靜態文件會被輸出到 public/ 目錄。如果想修改這個輸出路徑,可以通過在 Hugo 的配置文件(例如 config.toml、config.yaml 或 config.json)中設置 publishDir 來實現。
publishDir 設置以下是在 config.toml 文件中設置 publishDir 的範例:
publishDir = "my-custom-public"
如果你使用的是 config.yaml 文件,設置方式如下:
publishDir: "my-custom-public"
而在 config.json 中,你可以這樣設置:
{
"publishDir": "my-custom-public"
}
打開你的 Hugo 項目的根目錄下的配置文件(config.toml、config.yaml 或 config.json)。
添加或修改 publishDir 設置,將其值設為你希望的輸出目錄名稱。例如,如果你想將靜態文件輸出到名為 output 的目錄,你可以這樣設置:
在 config.toml 中:
publishDir = "output"
在 config.yaml 中:
publishDir: "output"
在 config.json 中:
{
"publishDir": "output"
}
保存配置文件。
接下來,當你運行 hugo 命令生成靜態文件時,它們會被輸出到設置的目錄(例如 output/)中,而不是默認的 public/ 目錄。