> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/gohugoio/hugo) · [上游 README](https://github.com/gohugoio/hugo/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
[Clang]: https://clang.llvm.org/
[GCC]: https://gcc.gnu.org/
[Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
[Go]: https://go.dev/doc/install
[bep]: https://github.com/bep
[bugs]: https://github.com/gohugoio/hugo/issues?q=is%3Aopen+is%3Aissue+label%3ABug
[contributing]: CONTRIBUTING.md
[create a proposal]: https://github.com/gohugoio/hugo/issues/new?labels=Proposal%2C+NeedsTriage&template=feature_request.md
[dart sass]: https://gohugo.io/functions/css/sass/#dart-sass
[details]: https://gohugo.io/host-and-deploy/deploy-with-hugo-deploy/
[documentation repository]: https://github.com/gohugoio/hugoDocs
[documentation]: https://gohugo.io/documentation
[dragonfly bsd, freebsd, netbsd, and openbsd]: https://gohugo.io/installation/bsd
[features]: https://gohugo.io/about/features/
[forum]: https://discourse.gohugo.io
[friends]: https://github.com/gohugoio/hugo/graphs/contributors
[hugo modules]: https://gohugo.io/hugo-modules/
[installation]: https://gohugo.io/installation
[issue queue]: https://github.com/gohugoio/hugo/issues
[linux]: https://gohugo.io/installation/linux
[macos]: https://gohugo.io/installation/macos
[prebuilt binary]: https://github.com/gohugoio/hugo/releases/latest
[requesting help]: https://discourse.gohugo.io/t/requesting-help/9132
[spf13]: https://github.com/spf13
[static site generator]: https://en.wikipedia.org/wiki/Static_site_generator
[support]: https://discourse.gohugo.io
[themes]: https://themes.gohugo.io/
[transpile sass to css]: https://gohugo.io/functions/css/sass/
[website]: https://gohugo.io
[windows]: https://gohugo.io/installation/windows
一款由 [bep][]、[spf13][] 和 [friends][] 使用 Go 语言倾心构建的快速、灵活的静态站点生成器(static site generator)。
---
[](https://godoc.org/github.com/gohugoio/hugo)
[](https://github.com/gohugoio/hugo/actions?query=workflow%3ATest)
[](https://goreportcard.com/report/github.com/gohugoio/hugo)
[Website(官网)][] | [Installation(安装)][] | [Documentation(文档)][] | [Support(支持)][] | [Contributing(贡献)][] | Mastodon
## 概述
Hugo 是一款使用 Go 语言编写的[静态站点生成器][static site generator],针对速度进行了优化,并兼顾灵活性设计。凭借其先进的模板系统和快速的资源管道(asset pipelines),Hugo 能在数秒内(通常更短)渲染一个完整的站点。
得益于其灵活的框架、多语言支持和强大的分类系统(taxonomy system),Hugo 被广泛用于创建:
- 企业、政府、非营利、教育、新闻、活动和项目站点
- 文档站点
- 图片作品集
- 落地页(Landing pages)
- 商业、专业和个人博客
- 简历和履历
在开发过程中,使用 Hugo 内置的 Web 服务器即可即时查看内容、结构、行为和展示的变化。然后将站点部署到你的主机上,或将更改推送到你的 Git 服务提供商以实现自动构建和部署。
Hugo 的快速资源管道包括:
- CSS 处理 – 打包、转换(transform)、压缩(minify)、生成 source maps、执行 SRI 哈希(SRI hashing),并与 PostCSS 集成。
- 图片处理 – 转换、调整尺寸、裁剪、旋转、调整颜色、应用滤镜、叠加文字和图片,以及提取元数据。
- JavaScript 打包 – 将 TypeScript 和 JSX 转译为 JavaScript,打包、摇树优化(tree shake)、压缩、生成 source maps,并执行 SRI 哈希。
- Sass 处理 – 将 Sass 转译为 CSS,打包、摇树优化、压缩、生成 source maps、执行 SRI 哈希,并与 PostCSS 集成。
- Tailwind CSS 处理 – 将 Tailwind CSS 实用类(utility classes)编译为标准 CSS,打包、摇树优化、优化、压缩、执行 SRI 哈希,并与 PostCSS 集成。
借助 [Hugo Modules][],你可以通过公共或私有的 Git 仓库与其他项目共享内容、资源、数据、翻译、主题、模板和配置。
请参阅文档的 [features][] 部分,了解 Hugo 功能的全面概述。
## 赞助商
## 版本 Hugo 提供多个版本。除非你需要额外功能,否则请使用标准版(standard edition)。 功能|standard|deploy|extended|extended/deploy :--|:-:|:-:|:-:|:-: 核心功能|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark: 直接云端部署 (1)|:x:|:heavy_check_mark:|:x:|:heavy_check_mark: LibSass 支持 (2)|:x:|:x:|:heavy_check_mark:|:heavy_check_mark: (1) 将你的站点直接部署到 Google Cloud Storage 存储桶、AWS S3 存储桶或 Azure Storage 容器。详见 [details][]。 (2) 通过内嵌的 LibSass [将 Sass 转译为 CSS][transpile sass to css]。请注意,内嵌 LibSass 自 v0.153.0 起已弃用,并将在未来版本中移除。请改用 [Dart Sass][] 转译器,该转译器兼容所有版本。 ## 安装 从[预编译二进制文件][prebuilt binary]、包管理器或包仓库安装 Hugo。请参阅适用于你操作系统的安装说明: - [macOS][] - [Linux][] - [Windows][] - [DragonFly BSD、FreeBSD、NetBSD 和 OpenBSD][] ## 从源码构建 要从源码构建 Hugo,你必须安装: 1. [Git][] 1. [Go][] 1.26.0 或更高版本 ### 标准版(Standard edition) 构建并安装标准版: ```sh CGO_ENABLED=0 go install github.com/gohugoio/hugo@latest ``` ### 部署版(Deploy edition) 构建并安装部署版: ```sh CGO_ENABLED=0 go install -tags withdeploy github.com/gohugoio/hugo@latest ``` ### 扩展版(Extended edition) 构建并安装扩展版,首先安装 C 编译器,如 [GCC][] 或 [Clang][],然后运行以下命令。 ```sh CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest ``` ### 扩展/部署版(Extended/deploy edition) 构建并安装扩展/部署版,首先安装 C 编译器,如 [GCC][] 或 [Clang][],然后运行以下命令。 ```sh CGO_ENABLED=1 go install -tags extended,withdeploy github.com/gohugoio/hugo@latest ``` ## Star 历史 [](https://star-history.com/#gohugoio/hugo&Timeline) ## 文档 Hugo 的[文档][documentation]包含安装说明、快速入门指南、概念说明、参考信息和示例。 请将文档相关的问题和 Pull Request 提交到[文档仓库][documentation repository]。 ## 支持 请**不要使用 issue 队列**提问或进行故障排查。除非你确定你的问题是软件缺陷,否则请使用[论坛][forum]。 Hugo 的[论坛][forum]是一个活跃的用户和开发者社区,大家在这里回答问题、分享知识并提供示例。快速搜索超过 20,000 个主题往往就能回答你的问题。在提出第一个问题之前,请务必阅读有关[请求帮助][requesting help]的说明。 ## 贡献 你可以通过以下方式为 Hugo 项目做出贡献: - 在[论坛][forum]上回答问题 - 完善[文档][documentation] - 关注 [issue 队列][issue queue] - 创建或改进[主题][themes] - 修复 [bugs][] 请将文档相关的问题和 Pull Request 提交到[文档仓库][documentation repository]。 如果你有改进或新功能的点子,请在[论坛][]的"Feature"分类中创建一个新话题。这将帮助你: - 确认该功能是否已存在 - 评估兴趣度 - 完善概念 如果兴趣足够,再[撰写提案][]。在项目负责人接受提案之前,请勿提交拉取请求。 关于 Hugo 贡献的完整指南,请参阅[贡献指南](CONTRIBUTING.md)。 ## 许可证 Hugo 源代码的许可证见 [LICENSE](/LICENSE)。 我们还以二进制/WASM 形式捆绑了一些库: - [libwebp](https://github.com/webmproject/libwebp),)([BSD-3-Clause 许可证](https://github.com/webmproject/libwebp?tab=BSD-3-Clause-1-ov-file#readme))) - [Katex](https://github.com/KaTeX/KaTeX),)([MIT 许可证](https://github.com/KaTeX/KaTeX?tab=MIT-1-ov-file#readme))) - [QuickJS](https://github.com/bellard/quickjs?tab=License-1-ov-file#readme),)([许可证](https://github.com/bellard/quickjs?tab=License-1-ov-file#readme))) ## 依赖 Hugo 站在众多优秀开源库的肩膀上。运行 `hugo env --logLevel info` 可查看依赖列表。