search

Hugo 类似与 Hexo Jekyll Octopress 都是 静态网站生成器, Hexo 基于 Node.js 而 Hugo 基于 Golang, 此文章翻译 Hugo Doc Introduction 部分 用来纪念我蹩脚的 CET - 4

Hugo - 静态页面生成器

Hugo 是什么?

Hugo 是一个构建网站的框架. 从技术角度来说的话, Hugo 是一个静态网站生成器. 不同于其它动态构建网站的系统那样需要对每一次请求生成一个页面, Hugo 会在你创建内容时生成页面文件. 通常由于网站的浏览量远大于网站的编辑量, 所以 Hugo 能在充分地优化网站的浏览速度的同时还能提供十分友好的开发体验.

使用 Hugo 构建网站既快速又安全. Hugo 构建的站点可以部署到任何地方, 包括 Heroku, GoDaddy, DreamHost, GitHub Pages, Google Cloud Storage, Amazon S3, CloudFront, 同时还能使用 CNDs . Hugo 构建的站点 不像 Ruby, Python 还有 PHP 那样需要昂贵的保持运行程序, 并且不依赖任何数据库.

我们认为 Hugo 是一个理想的网站构建工具. 超短开发时间与重构时间, Hugo 带来了闪电般的迭代周期. 这对开发网站来说是至关重要的, 同时对生成内容来说也是十分有用的.

与众不同的 Hugo

网站生成器渲染内容到 HTML 文件. 大多数是 "动态网站生成器". 那就意味着每当有一个新用户访问时候 HTTP 服务器就会生成一个全新的 HTML 文件.

动态地生成页面同时意味着 HTTP 服务器需要足够大的内存和足够强劲的 CPU 支持 才能良好的运行. 否则用户就可能需要排队等待页面的动态生成.

没有人会希望用户等待太长时间, 所以动态网站生成器会缓存 HTML 文件. 当一个文件被缓存起来了, 一个副本就临时的储存在服务器中. 这极大缩短了之后请求的访问时间.

然而 Hugo 的缓存更胜一筹. 所有 HTML 文件 都提前在电脑上渲染出来. 在你部署到服务器之前你可以检查所有文件. 因此 HTML 文件不是动态动态生成的, 所以我们成 Hugo 是 "静态页面生成器".

不在 HTTP 服务器上运行网站生成器有许多好处.最明显的就是性能 - HTTP 非常适合传输静态文件. 因此相比动态网站 Hugo 可以有效地在内存和 CPU 不是特别好的服务器上提供提供更多的负载.

Hugo 有两个组件帮助你构建和测试网站. 其中将会是你最常使用的内置 HTTP 服务. 当你执行 hugo server, Hugo 渲染所有内容到 HTML 文件再在你电脑上启动 HTTP 服务, 最后页面将呈现在出来.

第二个组件将在你准备发布你网站的时候使用. 运行 Hugo 不需要任何其他操作, 使用 baseurl Hugo 将根据你的配置文件重建你所有的的网站.

Hugo 到底有多快?

https://youtu.be/CdiDYZ51a2o

Hugo 是做什么的?

从技术角度来说, Hugo 将所有源文件和模板当做输入来构建一个完整的网站.

Hugo 拥有如下特性:

  1. 一般

    • 快(~1ms 一个页面)
    • 跨平台(Mac, Linux, Windows 还有更多)
    • 安装简单
    • 良好的开发体验 - 自动刷新
    • 大量的主题支持
    • 部署到任何地方
  2. 结构

    • 简单的结构
    • 支持网站片段
    • 完全自定义 URLs
    • 支持可配置的分类,包括分类和标签。创建您自己的自定义内容的结构
    • 能根据你的需要对内容进行分类
    • 自动生成目录
    • 动态菜单创建
    • 优雅的 URLs 支持
    • 永久链接模式支持
    • 别名(重定向)
  3. 内容

    • 原生支持 Markdown
      • 支持其他语言通过拓展方法, 参考 支持的格式
    • 在 front matter 中支持 TOML, YAML, JSON
    • 完全自定义首页
    • 支持大量 content types
    • 自定义/自动 生成 摘要
    • Shortcodes能够完善 Markdown 内容
    • “Minutes to Read” 功能
    • “Wordcount” 功能
  4. 拓展特性

    • 集成 Disqus 评论
    • 集成 Google Analytics
    • 自动创建 RSS
    • 支持 Go, Amber 和 Ace 的 HTML 模板
    • 语法高亮 由 Pygments 支持

谁适合使用 Hugo

  • 相比在浏览器中写作更喜欢在编辑器里写作的人们
  • 想拥有自己网站但又不想要运行程序或者依赖数据库的人们
  • 适合想搭建博客, 公司站点, 个人博客, 作品集, 文档, 单页网站 或者 成千上万页面的网站的人们

为什么要编写 Hugo?

我编写 Hugo 只有几个简单的原因. 首先, 我对 WordPress 十分失望, 然后我寻找解决方法. WordPress 渲染得太慢了. 我不能按自己的想法高效地创建内容, 而且只能在线写帖子还伴随着大量的安全升级和许多恐怖的博客被攻击故事. 我讨厌在 HTML 写东西, 我更喜欢在简洁的 Markdown 下创作. 总的来说我感觉使用 Wordpress 写文章遇到的问题比它给我带来便利要多得多.

我关注过现有的一些静态网站生成器, 比如 Jekyll, Middleman 和 nanoc. 所有的这些静态网站生成器需要复杂的安装并且要花很长时间来渲染我数以千计的文章, 这超出了我可接受的范围. 我期待一个框架可以当我改变模板时候可以提供快速的反馈, 5分钟左右的渲染时间真的太慢了. 总得来说, 它们还是太博客化, 并且没有足够的能力支持不同类型的内容和灵活的URLs.

我想要开发一个快速,功能完整且没有依赖的的框架. Go language 似乎s拥有我需要的这些特性的一门语言. 我开始使用 Go 开发 Hugo, 并深深的爱上了 Go. 我希望你能享用 Hugo (并且为此做出贡献).

下一步

  • 安装 Hugo
  • 快速开始
  • 加入 Mailing List
  • 在 GitHub 为我们点赞
  • 论坛

Introduction 部分 蹩脚的翻译初步完成了, 之前我也玩过点点 Hexo, 现在我也迫不及待的想使用 Hugo 玩玩 以及Golang

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML vs. CSS and JavaScript: Comparing Web TechnologiesHTML vs. CSS and JavaScript: Comparing Web TechnologiesApr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.