Hugo博客部署

# 在MacOS下
brew install hugo

hugo

hugo is the main command, used to build your Hugo site.

Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go. # 一个快速而灵活的静态网站生成器

Complete documentation is available at https://gohugo.io/. # 完整的文档可在https://gohugo.io/

Usage:
  hugo [flags]
  hugo [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell # 为指定的shell生成自动补全脚本
  config      Print the site configuration # 打印网站配置
  convert     Convert your content to different formats # 将你的内容转换成不同的格式
  deploy      Deploy your site to a Cloud provider. # 将你的网站部署到云计算提供商
  env         Print Hugo version and environment info # 打印版本和环境信息
  gen         A collection of several useful generators. # 一些有用的生成器的集合
  help        Help about any command # 关于任何命令的帮助
  import      Import your site from others. # 从别人那里导入你的网站
  list        Listing out various types of content # 列出各种类型的内容
  mod         Various Hugo Modules helpers. # 各种Hugo模块的帮助工具
  new         Create new content for your site # 为你的网站创建新内容
  server      A high performance webserver # 一个高性能的网络服务器
  version     Print the version number of Hugo # 打印Hugo的版本号

Flags:
  -b, --baseURL string             hostname (and path) to the root, e.g. https://spf13.com/
  -D, --buildDrafts                include content marked as draft
  -E, --buildExpired               include expired content
  -F, --buildFuture                include content with publishdate in the future
      --cacheDir string            filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
      --cleanDestinationDir        remove files from destination not found in static directories
      --clock string               set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00
      --config string              config file (default is path/config.yaml|json|toml)
      --configDir string           config dir (default "config")
  -c, --contentDir string          filesystem path to content directory
      --debug                      debug output
  -d, --destination string         filesystem path to write files to
      --disableKinds strings       disable different kind of pages (home, RSS etc.)
      --enableGitInfo              add Git revision, date, author, and CODEOWNERS info to the pages
  -e, --environment string         build environment
      --forceSyncStatic            copy all files when static is changed.
      --gc                         enable to run some cleanup tasks (remove unused cache files) after the build
  -h, --help                       help for hugo
      --ignoreCache                ignores the cache directory
      --ignoreVendorPaths string   ignores any _vendor for module paths matching the given Glob pattern
  -l, --layoutDir string           filesystem path to layout directory
      --log                        enable Logging
      --logFile string             log File path (if set, logging enabled automatically)
      --minify                     minify any supported output format (HTML, XML etc.)
      --noBuildLock                don't create .hugo_build.lock file
      --noChmod                    don't sync permission mode of files
      --noTimes                    don't sync modification time of files
      --panicOnWarning             panic on first WARNING log
      --poll string                set this to a poll interval, e.g --poll 700ms, to use a poll based approach to watch for file system changes
      --printI18nWarnings          print missing translations
      --printMemoryUsage           print memory usage to screen at intervals
      --printPathWarnings          print warnings on duplicate target paths etc.
      --printUnusedTemplates       print warnings on unused templates.
      --quiet                      build in quiet mode
      --renderToMemory             render to memory (only useful for benchmark testing)
  -s, --source string              filesystem path to read files relative from
      --templateMetrics            display metrics about template executions
      --templateMetricsHints       calculate some improvement hints when combined with --templateMetrics
  -t, --theme strings              themes to use (located in /themes/THEMENAME/)
      --themesDir string           filesystem path to themes directory
      --trace file                 write trace to file (not useful in general)
  -v, --verbose                    verbose output
      --verboseLog                 verbose logging
  -w, --watch                      watch filesystem for changes and recreate as needed

Use "hugo [command] --help" for more information about a command.

下面为机翻版本的一些注释

  -b, --baseURL字符串主机名(和路径)到根目录,例如:https://spf13.com/
  -D, --buildDrafts 包括标记为草稿的内容
  -E, --buildExpired 包括过期的内容
  -F, --buildFuture 包括发布日期在未来的内容
      --cacheDir 字符串 文件系统的缓存目录路径。默认值:$TMPDIR/hugo_cache/。
      --cleanDestinationDir 删除在静态目录中找不到的目的地文件。
      --clock string 设置Hugo使用的时钟,例如: --clock 2021-11-06T22:30:00.00+09:00
      --config string 配置文件(默认为path/config.yaml|json|toml)
      --configDir string config dir (default "config")
  --c, --contentDir string 文件系统的内容目录路径
      --debug 调试输出
  -d, --destination 字符串 写入文件的文件系统路径
      --disableKinds 字符串 禁用不同类型的页面(主页、RSS等)。
      --enableGitInfo 在页面上添加Git修订版、日期、作者和CODEOWNERS信息
  --e, --environment string 构建环境
      --forceSyncStatic 在静态变化时复制所有文件。
      --gc 启用,以便在构建后运行一些清理任务(删除未使用的缓存文件)。
  -h, --help hugo的帮助
      --ignoreCache 忽略缓存目录
      --ignoreVendorPaths字符串 忽略任何与给定Glob模式匹配的模块路径的_vendor
  -l, --layoutDir string filesystem path to layout directory
      --log 启用日志记录
      --logFile string 日志文件路径(如果设置,自动启用日志)
      --minify minify 任何支持的输出格式(HTML、XML等)。
      --noBuildLock 不创建.hugo_build.lock文件
      --noChmod不同步文件的权限模式
      --noTimes不同步文件的修改时间
      --panicOnWarning 在第一条WARNING日志中就会产生恐慌。
      --poll string 将此设置为一个轮询间隔,例如 --poll 700ms,以使用基于轮询的方法来观察文件系统的变化。
      --printI18nWarnings 打印缺失的译文
      --printMemoryUsage 每隔一段时间在屏幕上打印内存使用情况
      --printPathWarnings 打印重复目标路径的警告等。
      --printUnusedTemplates 打印未使用模板的警告。
      --quiet 在安静模式下构建
      --renderToMemory 渲染到内存中(只对基准测试有用)。
  --s, --source字符串文件系统路径,从该路径读取文件。
      --templateMetrics 显示有关模板执行的指标
      --templateMetricsHints 当与-templateMetrics结合时,计算一些改进的提示。
  -t, --theme 使用的主题字符串(位于/themes/THEMENAME/)。
      --themesDir string 文件系统中的主题目录路径
      --trace文件 将跟踪信息写入文件(一般情况下没有用)。
  --v, --verbose 冗长的输出
      --verboseLog 详细的日志记录
  -w, --watch 观察文件系统的变化,并在需要时重新创建。

使用 "hugo [command] --help "来获得更多关于命令的信息。

主题

可以在hugo网站上到自己想要的主题,然后资源clonetheme/theme_name下。

theme/etch 主题应用到项目中,只需执行一下步骤:

  1. hugo new site hugo-blog 创建新的博客网站;
  2. cd hugo-blog
  3. git submodule add https://github.com/LukasJoswiak/etch.git themes/etch
  4. vim config.toml 编辑site配置文件 theme = 'etch'
  5. hugo server -D 运行网站
  6. localhost:1313 浏览器访问

常用命令

hugo new posts/blog.md # 新建博客,以markdown格式,打开content/_posts/blog.md进行编辑
hugo new about.md # 新建博客,可以在md中添加 menu: "main",然后查看效果