Hugo Documentation
repository·master·Indexed 22 days ago
https://github.com/gohugoio/hugodocsOfficial guides and references for the Hugo static site generator. Includes documentation on installation (standard, deploy, and extended editions), image processing specifications, reflect functions for image resources, page navigation methods like .NextInSection, and taxonomy management.
What's inside Hugo Docs
- Hugo is released under the Apache License, Version 2.0 (January 2004). This license governs the use, reproduction, and distribution of the software.
Content Authoring in Hugo
masterHugo supports diverse content authoring workflows:
- Supported Formats: Markdown (default, conforming to CommonMark and GitHub Flavored Markdown), HTML, AsciiDoc, Emacs Org Mode, Pandoc, and reStructuredText.
- Markdown Enhancements:
- Attributes: Apply HTML
classandidto images and block elements (blockquotes, code blocks, headings, etc.). - Extensions: Use built-in extensions for tables, definition lists, footnotes, task lists, and more.
- Render Hooks: Override how Markdown elements (images, links, tables, etc.) are converted to HTML (e.g., rendering images as
<figure>elements).
- Attributes: Apply HTML
- Advanced Content Features:
- Diagrams: Include diagrams via fenced code blocks and render hooks.
- Mathematics: Use LaTeX markup for equations.
- Syntax Highlighting: Built-in support for hundreds of languages, enabled by default for fenced code blocks.
- Shortcodes: Insert complex content (audio, video, remote data tables) using embedded or custom shortcodes.
Explore commercial front-end interfaces for Hugo
masterIf you prefer a graphical user interface (GUI) over a text editor, several commercial services provide CMS (Content Management System) capabilities for Hugo sites:
- CloudCannon: A Git-based CMS that syncs with your repository. It features visual editing and allows building pages with reusable custom components.
- DatoCMS: A fully customizable administrative area for static websites, allowing clients to publish content independently.
- GitCMS: An AI-focused CMS for markdown content. It integrates Content Agents for ChatGPT and Claude via MCP and provides a Notion-like interface for non-technical users.
- HugoKit: A native macOS application designed to manage Hugo sites without a terminal. It handles the development server, content/template previews, front matter editing, site checks, and publishing to GitHub Pages or SFTP.
- Sitepins: A Git-based CMS offering a visual editor, media management, role-based permissions, and shortcode support. Setup involves connecting a GitHub repository and configuring content folders.
Explore open-source front-end interfaces for Hugo
masterSeveral open-source tools provide interfaces for managing Hugo content:
- Decap CMS: A serverless, open-source solution for managing Git-based content. A Hugo/Decap CMS starter is available for quick setup.
- Pages CMS: A Git-based CMS that allows editing Hugo content stored in GitHub via a web interface, supporting front matter, media management, and rich text editing.
- Quiqr Desktop: A cross-platform, offline desktop CMS with built-in Git functionality for deploying static sites.
- Sveltia CMS: A drop-in replacement for Decap CMS built with Svelte. It focuses on high performance, modern UI, and deep i18n (internationalization) support.
External learning resources for Hugo
masterWhen learning Hugo, you can utilize various third-party books and video tutorials.
Important Note on Versioning: Many external resources (especially older books and videos) may contain out-of-date information. Hugo has introduced significant changes, including a new template system, deprecated functions/settings, and new features like Markdown render hooks, content adapters, and mathematical markup support. Always consult the official Hugo documentation for the most current and accurate information.
Explore open-source search tools for Hugo
masterHugo allows you to implement custom search functionality by indexing your content files directly, providing an alternative to third-party embeddable scripts. Several open-source libraries and workflows are available depending on your technical requirements:
- Pagefind: A fully static search library optimized for large sites and minimal user bandwidth.
- lunr.js based solutions:
hugo-lunr: Creates an index of HTML and Markdown documents.hugo-lunr-zh: A version ofhugo-lunroptimized for Chinese keyword separation.- GitHub Gist for Hugo Workflow: Uses a Grunt script to index content for
lunr.js.
- Fuse.js based solutions:
- GitHub Gist for Fuse.js integration: Leverages Hugo's build-time processing to generate a searchable JSON index. Does not require npm or Grunt.
hugofastsearch: A global, keyboard-optimized update to the Fuse.js integration.- JS & Fuse.js tutorial: A simple client-side solution using FuseJS (no jQuery required).
- Other specialized tools:
hugo-search-index: Uses Gulp tasks and a prebuilt browser script to generate indexes from Markdown.- Hugo Lyra: A JavaScript module that integrates Lyra, providing both server-side indexing and an optional client-side library.
- INFINI Pizza (WebAssembly): A lightweight Rust-based search engine. Can be integrated with only three lines of code.
Supported content formats in Hugo
masterHugo allows you to mix different content formats throughout your site. You can create content using Markdown, HTML, Emacs Org Mode, AsciiDoc, Pandoc, or reStructuredText.
Regardless of the format used, all content files must include [front matter], and it is recommended to include at least a
titleand adate.Hugo determines which renderer to use based on the
markupidentifier specified in the front matter. If nomarkupidentifier is provided, Hugo falls back to using the file extension to select the renderer.Add syntax highlighting to code examples
masterHugo provides three primary methods to implement syntax highlighting in your project:
- Fenced code blocks: Use standard Markdown fenced code blocks within your content files.
highlightshortcode: Use the{{% highlight ... %}}shortcode within any supported content format.transform.Highlightfunction: Call this function directly within your Hugo templates for programmatic control.
For standard content creation, using fenced code blocks is the most common approach.
Hugo Asset Pipelines
masterHugo includes built-in processing for various web assets:
- CSS: Bundling, transformation, minification, source maps, SRI hashing, and PostCSS integration.
- Image Processing: Resizing, cropping, rotating, color adjustment, filtering, text/image overlays, and metadata extraction.
- JavaScript: Transpilation (TypeScript/JSX), bundling, tree shaking, minification, source maps, and SRI hashing.
- Sass: Transpilation to CSS, bundling, tree shaking, minification, source maps, and PostCSS integration.
- Tailwind CSS: Compilation of utility classes, bundling, tree shaking, optimization, minification, and PostCSS integration.
Hugo Framework Capabilities
masterHugo provides a comprehensive framework for building static sites with the following core capabilities:
- Multiplatform Support: Single executable available for Linux, macOS, Windows, and more.
- Multilingual Framework: Supports localization for languages and regions, including translations for images, dates, currencies, numbers, and collation sequences. Supports both single-host and multihost configurations.
- Output Formats: Render pages to multiple formats (HTML, JSON, RSS, CSV, etc.) with granular control by page kind, section, and path.
- Templates: Use variables, functions, and methods to transform content and data into published pages for any output format.
- Themes: Access community-contributed themes for various site types (blogs, documentation, portfolios, etc.).
- Modules: Create or import packaged combinations of archetypes, assets, content, data, templates, and configuration.
- Security Model: Built on a trust model where template/configuration authors are trusted, but content authors are not, ensuring HTML output is safe against code injection. Includes protections against shelling out, limits on environment variables, and remote data source restrictions.
Use the Hugo Command Line Interface (CLI)
masterThe Hugo CLI is the primary tool for managing your Hugo project. It allows you to build your site, run a local development server, manage assets, and perform various administrative tasks via the terminal.Explore commercial search services for Hugo
masterFor managed or high-scale search requirements, several commercial services can be integrated with Hugo:
- Algolia DocSearch: A free service specifically for public technical documentation sites. For other use cases, the Algolia Search API provides full-text, numerical, faceted, and geolocalized search.
- Bonsai: A fully-managed hosted Elasticsearch service. It provides specific guides for ingesting Hugo documents into Elasticsearch.
- ExpertRec: A hosted search-as-a-service solution that features a dashboard for modifying search settings without writing code.