这是一个使用 hugo-book 主题构建的 Hugo 网站。
docker-compose up -d
访问 http://localhost:8080 查看网站。
# 构建镜像
docker build -t hugo-book-site .
# 运行容器
docker run -p 8080:80 hugo-book-site
# 安装主题
git clone https://github.com/alex-shpak/hugo-book.git themes/hugo-book
# 启动开发服务器(带草稿预览)
hugo server -D
访问 http://localhost:1313 查看效果。
. ├── content/ # 内容目录 │ ├── _index.md # 首页 │ ├── docs/ # 文档部分 │ └── posts/ # 文章部分 ├── config.toml # 配置文件 ├── Dockerfile # Docker 镜像构建文件 ├── docker-compose.yml └── nginx.conf # Nginx 配置
hugo new posts/new-post.md
hugo new docs/new-page.md
编辑 config.toml 文件来自定义网站:
baseURL = 'https://your-domain.com/'
languageCode = 'zh-cn'
title = '你的网站标题'
[params]
BookTheme = 'light' # light, auto, dark
BookToC = true # 显示目录
BookSearch = true # 启用搜索
构建后的静态文件在 Docker 容器的 /usr/share/nginx/html 目录。
可以直接部署到: