Docker 方式部署 Hugo 博客
背景 这次用 Docker 方式部署 Hugo 博客,避免在本地安装 Hugo 环境,同时支持热重载方便写作。本文记录从零开始到生产部署的完整过程。 环境信息 系统:macOS 博客目录:/Users/xhsui/Library/CloudStorage/SynologyDrive-content/Hugo 容器镜像:hugomods/hugo:exts(支持 Sass/SCSS) 主题:PaperMod 域名:<ADDRESS_INFO_REPLACED> 完整部署步骤 1. 设置环境变量 export HUGO_PATH="/Users/xhsui/Library/CloudStorage/SynologyDrive-content/Hugo" 2. 初始化 Hugo 站点 docker run --rm \ -v "${HUGO_PATH}:/src" \ hugomods/hugo:exts \ new site . --force 3. 安装主题(PaperMod) cd "${HUGO_PATH}" git clone https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod 4. 创建配置文件 创建 hugo.toml(注意:Hugo 0.110+ 推荐使用 .toml 格式): baseURL = 'https://blog.xhsui.com/' title = 'xhsui blog' theme = 'PaperMod' defaultContentLanguage = 'zh-cn' enableInlineShortcodes = true [params] locale = 'zh-cn' mainSections = ["tech", "health"] showSummary = true showReadingTime = true ShowShareButtons = false ShowPostNavLinks = true ShowCodeCopyButtons = true [params.homeInfoParams] Title = "欢迎来到我的博客" Content = "这里记录了我的技术学习和健康生活点滴。" # 菜单配置 [menu] [[menu.main]] identifier = "tech" name = "技术" url = "/tech/" weight = 10 [[menu.main]] identifier = "health" name = "健康" url = "/health/" weight = 20 [[menu.main]] identifier = "tags" name = "标签" url = "/tags/" weight = 30 [pagination] pagerSize = 10 ⚠️ 关键配置说明: ...