Hugo 快速参考指南

有用的 Hugo 命令参数

目录

Hugo 是一个静态网站生成器。它可以帮助从标记、主题中生成 HTML 并保持网站的组织性。
例如 这个技术博客
以下是 Hugo 命令及其参数 的最常用列表:

一个机器人举着一块写着“Hugo Rulez”的牌子

网站创建与管理

  • 创建新网站:hugo new site <site-name> -f yml
  • 创建新内容:hugo new <content-path>
  • 构建网站:hugo
  • 构建网站并包含草稿内容:hugo -D
  • 本地运行网站:hugo server
  • 运行网站并包含草稿内容:hugo server -D

内容管理

  • 添加新文章:hugo new posts/<post-name>.md
  • 添加新页面:hugo new <page-name>.md

主题管理

  • 添加主题:git submodule add <theme-repo-url> themes/<theme-name>
  • 使用主题:在 config.toml 中添加 theme = "<theme-name>"

构建选项

  • 指定输出目录:hugo -d <directory>
  • 使用基础 URL 构建:hugo -b <URL>
  • 压缩输出:hugo --minify

服务器选项

  • 指定端口:hugo server -p <port-number>
  • 绑定到特定 IP:hugo server --bind <ip-address>
  • 监听更改:hugo server -w
  • 禁用实时重新加载:hugo server --disableLiveReload

调试

  • 显示详细输出:hugo -v
  • 设置日志级别:hugo --log-level <level>(debug, info, warn, error)

工具命令

  • 查看版本:hugo version
  • 清除构建缓存:hugo --cleanDestinationDir
  • 列出所有页面:hugo list all
  • 打印网站配置:hugo config

使用这些命令时,请将占位符(用 < > 包裹)替换为实际值。

希望 这个 能有所帮助。

有用的链接