# Table of Contents
- [Hugo Documentation](#hugo-documentation)
- [About Hugo](#about-hugo)
- [Command line interface](#command-line-interface)
- [New template system in Hugo v0.146.0](#new-template-system-in-hugo-v0-146-0)
- [Configuration](#configuration)
- [Content management](#content-management)
- [Developer tools](#developer-tools)
- [Contribute to the Hugo project](#contribute-to-the-hugo-project)
- [Functions](#functions)
- [Getting started](#getting-started)
- [Editor plugins](#editor-plugins)
- [Host and deploy](#host-and-deploy)
- [Hugo Modules](#hugo-modules)
- [Hugo Pipes](#hugo-pipes)
- [Installation](#installation)
- [Introduction](#introduction)
- [Introduction](#introduction)
- [News](#news)
- [Quick reference guides](#quick-reference-guides)
- [Render hooks](#render-hooks)
- [Introduction](#introduction)
- [Quick start](#quick-start)
- [Methods](#methods)
- [macOS](#macos)
- [Shortcodes](#shortcodes)
- [Hugo Pipes](#hugo-pipes)
- [Troubleshooting](#troubleshooting)
- [Introduction](#introduction)
- [Front-end interfaces](#front-end-interfaces)
- [Use Hugo Modules](#use-hugo-modules)
- [Search tools](#search-tools)
- [Theme components](#theme-components)
- [Templates](#templates)
- [Basic usage](#basic-usage)
- [License](#license)
- [External learning resources](#external-learning-resources)
- [Security model](#security-model)
- [Other community projects](#other-community-projects)
- [Directory structure](#directory-structure)
- [Migrate to Hugo](#migrate-to-hugo)
- [Template lookup order](#template-lookup-order)
- [Linux](#linux)
- [BSD](#bsd)
- [Windows](#windows)
- [Sitemap templates](#sitemap-templates)
- [Abs](#abs)
- [Custom 404 page](#custom-404-page)
- [RSS templates](#rss-templates)
- [Site audit](#site-audit)
- [Features](#features)
- [Menu templates](#menu-templates)
- [robots.txt template](#robots-txt-template)
- [Categories](#categories)
- [Alphabetical](#alphabetical)
- [Partial decorators](#partial-decorators)
- [Minify](#minify)
- [Template types](#template-types)
- [Introduction to templating](#introduction-to-templating)
- [Cast functions](#cast-functions)
- [ByName](#byname)
- [cast.ToInt](#cast-toint)
- [cast.ToFloat](#cast-tofloat)
- [cast.ToString](#cast-tostring)
- [Blockquote render hooks](#blockquote-render-hooks)
- [Embedded partial templates](#embedded-partial-templates)
- [ByCount](#bycount)
- [ByWeight](#byweight)
- [and](#and)
- [break](#break)
- [block](#block)
- [Add](#add)
- [Code block render hooks](#code-block-render-hooks)
- [After](#after)
- [AddDate](#adddate)
- [AllPages](#allpages)
- [All settings](#all-settings)
- [Children](#children)
- [Compare functions](#compare-functions)
- [Before](#before)
- [compare.Conditional](#compare-conditional)
- [Shortcode templates](#shortcode-templates)
- [Pagination](#pagination)
- [compare.Default](#compare-default)
- [compare.Gt](#compare-gt)
- [compare.Eq](#compare-eq)
- [compare.Ge](#compare-ge)
- [compare.Lt](#compare-lt)
- [compare.Le](#compare-le)
- [Crypto functions](#crypto-functions)
- [Archetypes](#archetypes)
- [ByExpiryDate](#byexpirydate)
- [ByDate](#bydate)
- [ByLastmod](#bylastmod)
- [compare.Ne](#compare-ne)
- [crypto.MD5](#crypto-md5)
- [crypto.HMAC](#crypto-hmac)
- [crypto.SHA1](#crypto-sha1)
- [CSS functions](#css-functions)
- [Debug functions](#debug-functions)
- [BuildDrafts](#builddrafts)
- [ByLength](#bylength)
- [ByLinkTitle](#bylinktitle)
- [crypto.FNV32a](#crypto-fnv32a)
- [crypto.SHA256](#crypto-sha256)
- [debug.Dump](#debug-dump)
- [debug.Timer](#debug-timer)
- [Diagram functions](#diagram-functions)
- [ByPublishDate](#bypublishdate)
- [ByParam](#byparam)
- [Concat](#concat)
- [css.Quoted](#css-quoted)
- [debug.VisualizeSpaces](#debug-visualizespaces)
- [ByTitle](#bytitle)
- [ByWeight](#byweight)
- [Count](#count)
- [css.Unquoted](#css-unquoted)
- [css.PostCSS](#css-postcss)
- [BaseURL](#baseurl)
- [ByLanguage](#bylanguage)
- [css.TailwindCSS](#css-tailwindcss)
- [Development](#development)
- [diagrams.Goat](#diagrams-goat)
- [Deprecation](#deprecation)
- [Encoding functions](#encoding-functions)
- [Build options](#build-options)
- [encoding.Base64Encode](#encoding-base64encode)
- [encoding.Base64Decode](#encoding-base64decode)
- [encoding.Jsonify](#encoding-jsonify)
- [Configure build](#configure-build)
- [Collections functions](#collections-functions)
- [continue](#continue)
- [css.Sass](#css-sass)
- [Global functions](#global-functions)
- [Duration methods](#duration-methods)
- [collections.Apply](#collections-apply)
- [collections.Append](#collections-append)
- [Documentation](#documentation)
- [collections.Delimit](#collections-delimit)
- [collections.After](#collections-after)
- [collections.Complement](#collections-complement)
- [collections.Dictionary](#collections-dictionary)
- [collections.First](#collections-first)
- [Deploy with rclone](#deploy-with-rclone)
- [Details shortcode](#details-shortcode)
- [Fmt functions](#fmt-functions)
- [Hash functions](#hash-functions)
- [collections.In](#collections-in)
- [fmt.Errorf](#fmt-errorf)
- [hash.FNV32a](#hash-fnv32a)
- [collections.Reverse](#collections-reverse)
- [collections.Intersect](#collections-intersect)
- [collections.Index](#collections-index)
- [collections.Slice](#collections-slice)
- [Deploy with rsync](#deploy-with-rsync)
- [fmt.Erroridf](#fmt-erroridf)
- [fmt.Printf](#fmt-printf)
- [fmt.Print](#fmt-print)
- [fmt.Println](#fmt-println)
- [hash.XxHash](#hash-xxhash)
- [Configure file caches](#configure-file-caches)
- [collections.D](#collections-d)
- [collections.Group](#collections-group)
- [collections.IsSet](#collections-isset)
- [collections.Merge](#collections-merge)
- [collections.Seq](#collections-seq)
- [collections.Last](#collections-last)
- [collections.SymDiff](#collections-symdiff)
- [collections.Querify](#collections-querify)
- [Content](#content)
- [Fingerprint](#fingerprint)
- [fmt.Warnf](#fmt-warnf)
- [fmt.Warnidf](#fmt-warnidf)
- [Glob patterns](#glob-patterns)
- [Comments](#comments)
- [Configure cascade](#configure-cascade)
- [collections.Shuffle](#collections-shuffle)
- [collections.Uniq](#collections-uniq)
- [collections.KeyVals](#collections-keyvals)
- [collections.Union](#collections-union)
- [Figure shortcode](#figure-shortcode)
- [Deploy with hugo](#deploy-with-hugo)
- [Content formats](#content-formats)
- [define](#define)
- [Get](#get)
- [collections.Sort](#collections-sort)
- [Colors](#colors)
- [Frequently asked questions](#frequently-asked-questions)
- [collections.NewScratch](#collections-newscratch)
- [Copyright](#copyright)
- [Crop](#crop)
- [else](#else)
- [end](#end)
- [Data](#data)
- [First](#first)
- [Config](#config)
- [Data sources](#data-sources)
- [Day](#day)
- [Get](#get)
- [Content adapters](#content-adapters)
- [collections.Where](#collections-where)
- [Data](#data)
- [Exif](#exif)
- [Err](#err)
- [Go template functions, operators, and statements](#go-template-functions-operators-and-statements)
- [Configure content types](#configure-content-types)
- [HasChildren](#haschildren)
- [Dimension](#dimension)
- [Equal](#equal)
- [Fill](#fill)
- [Fit](#fit)
- [GroupBy](#groupby)
- [GroupByParam](#groupbyparam)
- [GroupByDate](#groupbydate)
- [GroupByLastmod](#groupbylastmod)
- [GroupByExpiryDate](#groupbyexpirydate)
- [GroupByPublishDate](#groupbypublishdate)
- [GroupByParamDate](#groupbyparamdate)
- [Configure deployment](#configure-deployment)
- [Format](#format)
- [GetPage](#getpage)
- [Configure front matter](#configure-front-matter)
- [Diagrams](#diagrams)
- [Emojis](#emojis)
- [Filter](#filter)
- [Glossary](#glossary)
- [AllTranslations](#alltranslations)
- [AlternativeOutputFormats](#alternativeoutputformats)
- [Ancestors](#ancestors)
- [Aliases](#aliases)
- [Front matter](#front-matter)
- [BundleType](#bundletype)
- [CodeOwners](#codeowners)
- [Content](#content)
- [ContentWithoutSummary](#contentwithoutsummary)
- [CurrentSection](#currentsection)
- [Date](#date)
- [Data](#data)
- [Description](#description)
- [Draft](#draft)
- [Eq](#eq)
- [ExpiryDate](#expirydate)
- [FirstSection](#firstsection)
- [File](#file)
- [FuzzyWordCount](#fuzzywordcount)
- [Fragments](#fragments)
- [GetTerms](#getterms)
- [GetPage](#getpage)
- [GitInfo](#gitinfo)
- [HasMenuCurrent](#hasmenucurrent)
- [Functions](#functions)
---
# Hugo Documentation
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### About\
\
Learn about Hugo and its features, privacy protections, and security model.](https://gohugo.io/about/)
[### CLI\
\
Use the command line interface (CLI) to manage your project.](https://gohugo.io/commands/)
[### Configuration\
\
Configure your site.](https://gohugo.io/configuration/)
[### Content management\
\
Hugo makes managing large static sites easy with support for archetypes, content types, menus, cross references, summaries, and more.](https://gohugo.io/content-management/)
[### Contribute\
\
Contribute to development, documentation, and themes.](https://gohugo.io/contribute/)
[### Developer tools\
\
Third-party tools to help you create and manage sites.](https://gohugo.io/tools/)
[### Functions\
\
Use these functions within your templates and archetypes.](https://gohugo.io/functions/)
[### Getting started\
\
How to get started with Hugo.](https://gohugo.io/getting-started/)
[### Host and deploy\
\
Services and tools to host and deploy your site.](https://gohugo.io/host-and-deploy/)
[### Hugo Modules\
\
Use Hugo Modules to manage the content, presentation, and behavior of your site.](https://gohugo.io/hugo-modules/)
[### Hugo Pipes\
\
Use asset pipelines to transform and optimize images, stylesheets, and JavaScript.](https://gohugo.io/hugo-pipes/)
[### Installation\
\
Install Hugo on macOS, Linux, Windows, BSD, and on any machine that can run the Go compiler tool chain.](https://gohugo.io/installation/)
[### Methods\
\
Use these methods within your templates.](https://gohugo.io/methods/)
[### News\
\
Stay up-to-date with the latest news and announcements.](https://gohugo.io/news/)
[### Quick reference\
\
Use these quick reference guides for quick access to key information.](https://gohugo.io/quick-reference/)
[### Render hooks\
\
Create render hook templates to override the rendering of Markdown to HTML.](https://gohugo.io/render-hooks/)
[### Shortcodes\
\
Insert elements such as videos, images, and social media embeds into your content using Hugo's embedded shortcodes.](https://gohugo.io/shortcodes/)
[### Templates\
\
Create templates to render your content, resources, and data.](https://gohugo.io/templates/)
[### Troubleshooting\
\
Use these techniques when troubleshooting your site.](https://gohugo.io/troubleshooting/)
---
# About Hugo
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Introduction\
\
Hugo is a static site generator written in Go, optimized for speed and designed for flexibility.](https://gohugo.io/about/introduction/)
[### Features\
\
Hugo's rich and powerful feature set provides the framework and tools to create static sites that build in seconds, often less.](https://gohugo.io/about/features/)
[### Security\
\
A summary of Hugo's security model.](https://gohugo.io/about/security/)
[### License\
\
Hugo is released under the Apache 2.0 license.](https://gohugo.io/about/license/)
---
# Command line interface
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### hugo\
\
Build your project.](https://gohugo.io/commands/hugo/)
[### hugo build\
\
Build your project.](https://gohugo.io/commands/hugo_build/)
[### hugo completion\
\
Generate the autocompletion script for the specified shell.](https://gohugo.io/commands/hugo_completion/)
[### hugo completion bash\
\
Generate the autocompletion script for bash.](https://gohugo.io/commands/hugo_completion_bash/)
[### hugo completion fish\
\
Generate the autocompletion script for fish.](https://gohugo.io/commands/hugo_completion_fish/)
[### hugo completion powershell\
\
Generate the autocompletion script for powershell.](https://gohugo.io/commands/hugo_completion_powershell/)
[### hugo completion zsh\
\
Generate the autocompletion script for zsh.](https://gohugo.io/commands/hugo_completion_zsh/)
[### hugo config\
\
Display project configuration.](https://gohugo.io/commands/hugo_config/)
[### hugo config mounts\
\
Print the configured file mounts.](https://gohugo.io/commands/hugo_config_mounts/)
[### hugo convert\
\
Convert front matter to another format.](https://gohugo.io/commands/hugo_convert/)
[### hugo convert toJSON\
\
Convert front matter to JSON.](https://gohugo.io/commands/hugo_convert_tojson/)
[### hugo convert toTOML\
\
Convert front matter to TOML.](https://gohugo.io/commands/hugo_convert_totoml/)
[### hugo convert toYAML\
\
Convert front matter to YAML.](https://gohugo.io/commands/hugo_convert_toyaml/)
[### hugo deploy\
\
Deploy your project to a cloud provider.](https://gohugo.io/commands/hugo_deploy/)
[### hugo env\
\
Display version and environment info.](https://gohugo.io/commands/hugo_env/)
[### hugo gen\
\
Generate documentation and syntax highlighting styles.](https://gohugo.io/commands/hugo_gen/)
[### hugo gen chromastyles\
\
Generate CSS stylesheet for the Chroma code highlighter.](https://gohugo.io/commands/hugo_gen_chromastyles/)
[### hugo gen doc\
\
Generate Markdown documentation for the Hugo CLI.](https://gohugo.io/commands/hugo_gen_doc/)
[### hugo gen man\
\
Generate man pages for the Hugo CLI.](https://gohugo.io/commands/hugo_gen_man/)
[### hugo import\
\
Import a project from another system.](https://gohugo.io/commands/hugo_import/)
[### hugo import jekyll\
\
hugo import from Jekyll.](https://gohugo.io/commands/hugo_import_jekyll/)
[### hugo list\
\
List content.](https://gohugo.io/commands/hugo_list/)
[### hugo list all\
\
List all content.](https://gohugo.io/commands/hugo_list_all/)
[### hugo list drafts\
\
List draft content.](https://gohugo.io/commands/hugo_list_drafts/)
[### hugo list expired\
\
List expired content.](https://gohugo.io/commands/hugo_list_expired/)
[### hugo list future\
\
List future content.](https://gohugo.io/commands/hugo_list_future/)
[### hugo list published\
\
List published content.](https://gohugo.io/commands/hugo_list_published/)
[### hugo mod\
\
Manage modules.](https://gohugo.io/commands/hugo_mod/)
[### hugo mod clean\
\
Delete the Hugo Module cache for the current project.](https://gohugo.io/commands/hugo_mod_clean/)
[### hugo mod get\
\
Resolves dependencies in your current Hugo project.](https://gohugo.io/commands/hugo_mod_get/)
[### hugo mod graph\
\
Print a module dependency graph.](https://gohugo.io/commands/hugo_mod_graph/)
[### hugo mod init\
\
Initialize this project as a Hugo Module.](https://gohugo.io/commands/hugo_mod_init/)
[### hugo mod npm\
\
Various npm helpers.](https://gohugo.io/commands/hugo_mod_npm/)
[### hugo mod npm pack\
\
Experimental: Prepares and writes a composite package.json file for your project.](https://gohugo.io/commands/hugo_mod_npm_pack/)
[### hugo mod tidy\
\
Remove unused entries in go.mod and go.sum.](https://gohugo.io/commands/hugo_mod_tidy/)
[### hugo mod vendor\
\
Vendor all module dependencies into the \_vendor directory.](https://gohugo.io/commands/hugo_mod_vendor/)
[### hugo mod verify\
\
Verify dependencies.](https://gohugo.io/commands/hugo_mod_verify/)
[### hugo new\
\
Create new content.](https://gohugo.io/commands/hugo_new/)
[### hugo new content\
\
Create new content.](https://gohugo.io/commands/hugo_new_content/)
[### hugo new project\
\
Create a new project.](https://gohugo.io/commands/hugo_new_project/)
[### hugo new theme\
\
Create a new theme.](https://gohugo.io/commands/hugo_new_theme/)
[### hugo server\
\
Start the embedded web server.](https://gohugo.io/commands/hugo_server/)
[### hugo server trust\
\
Install the local CA in the system trust store.](https://gohugo.io/commands/hugo_server_trust/)
[### hugo version\
\
Display version.](https://gohugo.io/commands/hugo_version/)
---
# New template system in Hugo v0.146.0
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Overview of the new template system in Hugo v0.146.0.
In [Hugo v0.146.0](https://github.com/gohugoio/hugo/releases/tag/v0.146.0)
, we performed a full re-implementation of how Go templates are handled in Hugo. This includes structural changes to the `layouts` folder and a new, more powerful template lookup system.
We have aimed to maintain as much backward compatibility as possible by mapping “old to new,” but some reported breakages have occurred. We’re working on a full overhaul of the documentation on this topic – until then, this is a one-pager with the most important changes.
Changes to the `layouts` folder[](https://gohugo.io/templates/new-templatesystem-overview/#changes-to-the-layouts-folder)
--------------------------------------------------------------------------------------------------------------------------
| Description | Action required |
| --- | --- |
| The `_default` folder is removed. | Move all files in `layouts/_default` up to the `layouts/` root. |
| The `layouts/partials` folder is renamed to `layouts/_partials`. | Rename the folder. |
| The `layouts/shortcodes` folder is renamed to `layouts/_shortcodes`. | Rename the folder. |
| Any folder in `layouts` that does not start with `_` represents the root of a [Page path](https://gohugo.io/methods/page/path/) . In [Hugo v0.146.0](https://github.com/gohugoio/hugo/releases/tag/v0.146.0) , this can be nested as deeply as needed, and `_shortcodes` and `_markup` folders can be placed at any level in the tree. | No action required. |
| The above also means that there’s no top-level `layouts/taxonomy` or `layouts/section` folders anymore, unless it represents a [Page path](https://gohugo.io/methods/page/path/) . | Move them up to `layouts/` with one of the [Page kinds](https://gohugo.io/methods/page/kind/) `section`, `taxonomy` or `term` as the base name, or place the layouts into the taxonomy [Page path](https://gohugo.io/methods/page/path/) . |
| A template named `taxonomy.html` used to be a candidate for both Page kind `term` and `taxonomy`, now it’s only considered for `taxonomy`. | Create both `taxonomy.html` and `term.html` or create a more general layout, e.g. `list.html`. |
| For base templates (e.g., `baseof.html`), in previous Hugo versions, you could prepend one identifier (layout, type, or kind) with a hyphen in front of the baseof keyword. | Move that identifier after the first “dot,” e.g., rename`list-baseof.html` to `baseof.list.html`. |
| We have added a new `all` “catch-all” layout. This means that if you have, e.g., `layouts/all.html` and that is the only template, that layout will be used for all HTML page rendering. | |
| We have removed the concept of `_internal` Hugo templates.[1](https://gohugo.io/templates/new-templatesystem-overview/#fn:1) | Replace constructs similar to `{{ template "_internal/opengraph.html" . }}` with `{{ partial "opengraph.html" . }}`. |
| The identifiers that can be used in a template filename are one of the [Page kinds](https://gohugo.io/methods/page/kind/) (`home`, `page`, `section`, `taxonomy`, or `term`), one of the standard layouts (`list`, `single`, or `all`), a custom layout (as defined in the `layout` front matter field), a language (e.g., `en`), an output format (e.g., `html`, `rss`), and a suffix representing the media type. E.g., `all.en.html` and `home.rss.xml`. | |
| The above means that there’s no such thing as an `index.html` template for the home page anymore. | Rename `index.html` to `home.html`. |
Also, see the [Example folder structure](https://gohugo.io/templates/new-templatesystem-overview/#example-folder-structure)
below for a more concrete example of the new layout system.
Changes to template lookup order[](https://gohugo.io/templates/new-templatesystem-overview/#changes-to-template-lookup-order)
------------------------------------------------------------------------------------------------------------------------------
We have consolidated the template lookup so it works the same across all [template types](https://gohugo.io/templates/types/)
. The previous setup was very hard to understand and had a massive number of variants. The new setup aims to feel natural with few surprises.
The identifiers used in the template weighting, in order of importance, are:
| Identifier | Description |
| --- | --- |
| Layout custom | The custom `layout` set in front matter. |
| [Page kinds](https://gohugo.io/methods/page/kind/) | One of `home`, `section`, `taxonomy`, `term`, `page`. |
| Layouts standard 1 | `list` or `single`. |
| Output format | The output format (e.g., `html`, `rss`). |
| Layouts standard 2 | `all`. |
| Language | The language (e.g., `en`). |
| Media type | The media type (e.g., `text/html`). |
| [Page path](https://gohugo.io/methods/page/path/) | The page path (e.g., `/blog/mypost`). |
| Type | `type` set in front matter.[2](https://gohugo.io/templates/new-templatesystem-overview/#fn:2) |
For templates placed in a `layouts` folder partly or completely matching a [Page path](https://gohugo.io/methods/page/path/)
, a closer match upwards will be considered _better_. In the [Example folder structure](https://gohugo.io/templates/new-templatesystem-overview/#example-folder-structure)
below, this means that:
* `layouts/docs/api/_markup/render-link.html` will be used to render links from the Page path `/docs/api` and below.
* `layouts/docs/baseof.html` will be used as the base template for the Page path `/docs` and below.
* `layouts/tags/term.html` will be used for all `term` rendering in the `tags` taxonomy, except for the `blue` term, which will use `layouts/tags/blue/list.html`.
Example folder structure[](https://gohugo.io/templates/new-templatesystem-overview/#example-folder-structure)
--------------------------------------------------------------------------------------------------------------
layouts
├── baseof.html
├── baseof.term.html
├── home.html
├── page.html
├── section.html
├── taxonomy.html
├── term.html
├── term.mylayout.en.rss.xml
├── _markup
│ ├── render-codeblock-go.term.mylayout.no.rss.xml
│ └── render-link.html
├── _partials
│ └── mypartial.html
├── _shortcodes
│ ├── myshortcode.html
│ └── myshortcode.section.mylayout.en.rss.xml
├── docs
│ ├── baseof.html
│ ├── _shortcodes
│ │ └── myshortcode.html
│ └── api
│ ├── mylayout.html
│ ├── page.html
│ └── _markup
│ └── render-link.html
└── tags
├── taxonomy.html
├── term.html
└── blue
└── list.html
* * *
1. The old way of doing it made it very hard/impossible to, e.g., override `_internal/disqus.html` in a theme. Now you can just create a partial with the same name. [↩︎](https://gohugo.io/templates/new-templatesystem-overview/#fnref:1)
2. The `type` set in front matter will effectively replace the `section` folder in [Page path](https://gohugo.io/methods/page/path/)
when doing lookups. [↩︎](https://gohugo.io/templates/new-templatesystem-overview/#fnref:2)
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/new-templatesystem-overview.md)
---
# Configuration
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Introduction\
\
Configure your site using files, directories, and environment variables.](https://gohugo.io/configuration/introduction/)
[### All settings\
\
The complete list of Hugo configuration settings.](https://gohugo.io/configuration/all/)
[### Build\
\
Configure global build options.](https://gohugo.io/configuration/build/)
[### Caches\
\
Configure file caches.](https://gohugo.io/configuration/caches/)
[### Cascade\
\
Configure cascade.](https://gohugo.io/configuration/cascade/)
[### Content types\
\
Configure content types.](https://gohugo.io/configuration/content-types/)
[### Deployment\
\
Configure deployments to Amazon S3, Azure Blob Storage, or Google Cloud Storage.](https://gohugo.io/configuration/deployment/)
[### Front matter\
\
Configure front matter.](https://gohugo.io/configuration/front-matter/)
[### HTTP cache\
\
Configure the HTTP cache.](https://gohugo.io/configuration/http-cache/)
[### Imaging\
\
Configure imaging.](https://gohugo.io/configuration/imaging/)
[### Languages\
\
Configure the languages in your multilingual project.](https://gohugo.io/configuration/languages/)
[### Markup\
\
Configure markup.](https://gohugo.io/configuration/markup/)
[### Media types\
\
Configure media types.](https://gohugo.io/configuration/media-types/)
[### Menus\
\
Centrally define menu entries for one or more menus.](https://gohugo.io/configuration/menus/)
[### Minify\
\
Configure minify.](https://gohugo.io/configuration/minify/)
[### Modules\
\
Configure modules.](https://gohugo.io/configuration/module/)
[### Output formats\
\
Configure output formats.](https://gohugo.io/configuration/output-formats/)
[### Outputs\
\
Configure which output formats to render for each page kind.](https://gohugo.io/configuration/outputs/)
[### Page\
\
Configure page behavior.](https://gohugo.io/configuration/page/)
[### Pagination\
\
Configure pagination.](https://gohugo.io/configuration/pagination/)
[### Params\
\
Create custom site parameters.](https://gohugo.io/configuration/params/)
[### Permalinks\
\
Configure permalinks.](https://gohugo.io/configuration/permalinks/)
[### Privacy\
\
Configure your site to help comply with regional privacy regulations.](https://gohugo.io/configuration/privacy/)
[### Related content\
\
Configure related content.](https://gohugo.io/configuration/related-content/)
[### Roles\
\
Configure roles.](https://gohugo.io/configuration/roles/)
[### Security\
\
Configure security.](https://gohugo.io/configuration/security/)
[### Segments\
\
Configure your site for segmented rendering.](https://gohugo.io/configuration/segments/)
[### Server\
\
Configure the development server.](https://gohugo.io/configuration/server/)
[### Services\
\
Configure embedded templates.](https://gohugo.io/configuration/services/)
[### Sitemap\
\
Configure the sitemap.](https://gohugo.io/configuration/sitemap/)
[### Taxonomies\
\
Configure taxonomies.](https://gohugo.io/configuration/taxonomies/)
[### Ugly URLs\
\
Configure ugly URLs.](https://gohugo.io/configuration/ugly-urls/)
[### Versions\
\
Configure versions.](https://gohugo.io/configuration/versions/)
---
# Content management
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Archetypes\
\
An archetype is a template for new content.](https://gohugo.io/content-management/archetypes/)
[### Build options\
\
Build options help define how Hugo must treat a given page when building the site.](https://gohugo.io/content-management/build-options/)
[### Comments\
\
Hugo ships with an internal Disqus template, but this isn't the only commenting system that will work with your new Hugo website.](https://gohugo.io/content-management/comments/)
[### Content adapters\
\
Create content adapters to dynamically add content when building your project.](https://gohugo.io/content-management/content-adapters/)
[### Content formats\
\
Create your content using Markdown, HTML, Emacs Org Mode, AsciiDoc, Pandoc, or reStructuredText.](https://gohugo.io/content-management/formats/)
[### Data sources\
\
Use local and remote data sources to augment or create content.](https://gohugo.io/content-management/data-sources/)
[### Diagrams\
\
Use fenced code blocks and Markdown render hooks to include diagrams in your content.](https://gohugo.io/content-management/diagrams/)
[### Front matter\
\
Use front matter to add metadata to your content.](https://gohugo.io/content-management/front-matter/)
[### Image processing\
\
Transform images to change their size, shape, and appearance.](https://gohugo.io/content-management/image-processing/)
[### Markdown attributes\
\
Use Markdown attributes to add HTML attributes when rendering Markdown to HTML.](https://gohugo.io/content-management/markdown-attributes/)
[### Mathematics\
\
Include mathematical equations and expressions in Markdown using LaTeX markup.](https://gohugo.io/content-management/mathematics/)
[### Menus\
\
Create menus by defining entries, localizing each entry, and rendering the resulting data structure.](https://gohugo.io/content-management/menus/)
[### Multilingual\
\
Localize your project for each language and region, including translations, images, dates, currencies, numbers, percentages, and collation sequence. Hugo's multilingual framework supports single-host and multihost configurations.](https://gohugo.io/content-management/multilingual/)
[### Organization\
\
Hugo assumes that the same structure that works to organize your source content is used to organize the rendered site.](https://gohugo.io/content-management/organization/)
[### Page bundles\
\
Use page bundles to logically associate one or more resources with content.](https://gohugo.io/content-management/page-bundles/)
[### Page resources\
\
Use page resources to logically associate assets with a page.](https://gohugo.io/content-management/page-resources/)
[### Related content\
\
List related content in "See Also" sections.](https://gohugo.io/content-management/related-content/)
[### Sections\
\
Organize content into sections.](https://gohugo.io/content-management/sections/)
[### Shortcodes\
\
Use embedded, custom, or inline shortcodes to insert elements such as videos, images, and social media embeds into your content.](https://gohugo.io/content-management/shortcodes/)
[### Summaries\
\
Create and render content summaries.](https://gohugo.io/content-management/summaries/)
[### Syntax highlighting\
\
Add syntax highlighting to code examples.](https://gohugo.io/content-management/syntax-highlighting/)
[### Taxonomies\
\
Hugo includes support for user-defined taxonomies.](https://gohugo.io/content-management/taxonomies/)
[### URL management\
\
Control the structure and appearance of URLs through front matter entries and settings in your project configuration.](https://gohugo.io/content-management/urls/)
---
# Developer tools
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Editor plugins\
\
The Hugo community uses a wide range of tools and has developed plugins for some of the most popular text editors to help automate parts of your workflow.](https://gohugo.io/tools/editors/)
[### Front-ends\
\
Do you prefer a graphical user interface over a text editor? Give these front-ends a try.](https://gohugo.io/tools/front-ends/)
[### Search\
\
See some of the open-source and commercial search options for your newly created Hugo website.](https://gohugo.io/tools/search/)
[### Migrations\
\
A list of community-developed tools for migrating from your existing static site generator or content management system to Hugo.](https://gohugo.io/tools/migrations/)
[### Other projects\
\
Some interesting projects developed by the Hugo community that don't quite fit into our other developer tool categories.](https://gohugo.io/tools/other/)
---
# Contribute to the Hugo project
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Development\
\
Contribute to the development of Hugo.](https://gohugo.io/contribute/development/)
[### Documentation\
\
Help us to improve the documentation by identifying issues and suggesting changes.](https://gohugo.io/contribute/documentation/)
[### Themes\
\
If you've built a Hugo theme and want to contribute back to the Hugo Community, please share it with us.](https://gohugo.io/contribute/themes/)
---
# Functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### cast\
\
Use these functions to cast a value from one data type to another.](https://gohugo.io/functions/cast/)
[### collections\
\
Use these functions to manipulate and query maps, slices, and strings.](https://gohugo.io/functions/collections/)
[### compare\
\
Use these functions to compare two or more values.](https://gohugo.io/functions/compare/)
[### crypto\
\
Use these functions to create cryptographic hashes.](https://gohugo.io/functions/crypto/)
[### css\
\
Use these functions to work with CSS and Sass files.](https://gohugo.io/functions/css/)
[### debug\
\
Use these functions to debug your templates.](https://gohugo.io/functions/debug/)
[### diagrams\
\
Use these functions to render diagrams.](https://gohugo.io/functions/diagrams/)
[### encoding\
\
Use these functions to encode and decode data.](https://gohugo.io/functions/encoding/)
[### fmt\
\
Use these functions to print strings within a template or to print messages to the terminal.](https://gohugo.io/functions/fmt/)
[### global\
\
Use these global functions to access page and site data.](https://gohugo.io/functions/global/)
[### go template\
\
These are the functions, operators, and statements provided by Go's text/template package.](https://gohugo.io/functions/go-template/)
[### hash\
\
Use these functions to create non-cryptographic hashes.](https://gohugo.io/functions/hash/)
[### hugo\
\
Use these functions to access information about the Hugo application and the current environment.](https://gohugo.io/functions/hugo/)
[### images\
\
Use these functions to create an image filter, apply an image filter to an image, and to retrieve image information.](https://gohugo.io/functions/images/)
[### inflect\
\
These functions provide word inflection features such as singularization and pluralization of English nouns.](https://gohugo.io/functions/inflect/)
[### js\
\
Use these functions to work with JavaScript and TypeScript files.](https://gohugo.io/functions/js/)
[### lang\
\
Use these functions to adapt your site to meet language and regional requirements.](https://gohugo.io/functions/lang/)
[### math\
\
Use these functions to perform mathematical operations.](https://gohugo.io/functions/math/)
[### openapi3\
\
Use these functions to work with OpenAPI 3 definitions.](https://gohugo.io/functions/openapi3/)
[### os\
\
Use these functions to interact with the operating system.](https://gohugo.io/functions/os/)
[### partials\
\
Use these functions to call partial templates.](https://gohugo.io/functions/partials/)
[### path\
\
Use these functions to work with file paths.](https://gohugo.io/functions/path/)
[### reflect\
\
Use these functions to determine a value's data type.](https://gohugo.io/functions/reflect/)
[### resources\
\
Use these functions to work with resources.](https://gohugo.io/functions/resources/)
[### safe\
\
Use these functions to declare a value as safe in the context of Go's html/template package.](https://gohugo.io/functions/safe/)
[### strings\
\
Use these functions to work with strings.](https://gohugo.io/functions/strings/)
[### templates\
\
Use these functions to query the template system.](https://gohugo.io/functions/templates/)
[### time\
\
Use these functions to work with time values.](https://gohugo.io/functions/time/)
[### transform\
\
Use these functions to transform values from one format to another.](https://gohugo.io/functions/transform/)
[### urls\
\
Use these functions to work with URLs.](https://gohugo.io/functions/urls/)
---
# Getting started
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Quick start\
\
Create your first Hugo project.](https://gohugo.io/getting-started/quick-start/)
[### Basic usage\
\
Use the command-line interface (CLI) to perform basic tasks.](https://gohugo.io/getting-started/usage/)
[### Directory structure\
\
An overview of Hugo's directory structure.](https://gohugo.io/getting-started/directory-structure/)
[### External resources\
\
Use these third-party resources to learn Hugo.](https://gohugo.io/getting-started/external-learning-resources/)
---
# Editor plugins
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

The Hugo community uses a wide range of tools and has developed plugins for some of the most popular text editors to help automate parts of your workflow.
Visual Studio Code[](https://gohugo.io/tools/editors/#visual-studio-code)
--------------------------------------------------------------------------
[Front Matter](https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-front-matter)
[](https://gohugo.io/tools/editors/#front-matter)
Once you go for a static site, you need to think about how you are going to manage your articles. Front matter is a tool that helps you maintain the metadata/front matter of your articles like: creation date, modified date, slug, tile, SEO check, and more.
[Hugo Helper](https://marketplace.visualstudio.com/items?itemName=rusnasonov.vscode-hugo)
[](https://gohugo.io/tools/editors/#hugo-helper)
Hugo Helper is a plugin for Visual Studio Code that has some useful commands for Hugo. The source code can be found on its [GitHub repository](https://github.com/rusnasonov/vscode-hugo)
.
[Hugo Language and Syntax Support](https://marketplace.visualstudio.com/items?itemName=budparr.language-hugo-vscode)
[](https://gohugo.io/tools/editors/#hugo-language-and-syntax-support)
Hugo Language and Syntax Support is a Visual Studio Code plugin for Hugo syntax highlighting and snippets. The source code can be found on its [GitHub repository](https://github.com/budparr/language-hugo-vscode)
.
[Hugo Themer](https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-hugo-themer)
[](https://gohugo.io/tools/editors/#hugo-themer)
Hugo Themer is an extension to help you while developing themes. It allows you to easily navigate through your theme files.
[Hugofy](https://marketplace.visualstudio.com/items?itemName=akmittal.hugofy)
[](https://gohugo.io/tools/editors/#hugofy)
Hugofy is a plugin for Visual Studio Code to “make life easier” when developing with Hugo. The source code can be found on its [GitHub repository](https://github.com/akmittal/hugofy-vscode)
.
[Prettier Plugin for Go Templates](https://github.com/NiklasPor/prettier-plugin-go-template)
[](https://gohugo.io/tools/editors/#prettier-plugin-for-go-templates)
Format Hugo templates using this [Prettier](https://prettier.io/)
plugin. See [installation instructions](https://discourse.gohugo.io/t/38403)
.
[Syntax Highlighting for Hugo Shortcodes](https://marketplace.visualstudio.com/items?itemName=kaellarkin.hugo-shortcode-syntax)
[](https://gohugo.io/tools/editors/#syntax-highlighting-for-hugo-shortcodes)
This extension adds some syntax highlighting for Shortcodes, making visual identification of individual pieces easier.
JetBrains IDEs[](https://gohugo.io/tools/editors/#jetbrains-ides)
------------------------------------------------------------------
[Smart Hugo](https://smarthugo.dev/)
[](https://gohugo.io/tools/editors/#smart-hugo)
Plugin for IntelliJ IDEA, WebStorm, PhpStorm, and other JetBrains IDEs that adds Hugo template support including syntax highlighting, actions completion, code formatting, and optional advanced features.
Emacs[](https://gohugo.io/tools/editors/#emacs)
------------------------------------------------
[emacs-easy-hugo](https://github.com/masasam/emacs-easy-hugo)
[](https://gohugo.io/tools/editors/#emacs-easy-hugo)
Emacs major mode for managing hugo blogs. Note that Hugo also supports [Org-mode](https://gohugo.io/content-management/formats/)
.
[ox-hugo.el](https://ox-hugo.scripter.co/)
[](https://gohugo.io/tools/editors/#ox-hugoel)
Native Org-mode exporter that exports to Blackfriday Markdown with Hugo front-matter. `ox-hugo` supports two common Org blogging flows — exporting multiple Org subtrees in a single file to multiple Hugo posts, and exporting a single Org file to a single Hugo post. It also leverages the Org tag and property inheritance features. See [Why ox-hugo?](https://ox-hugo.scripter.co/doc/why-ox-hugo/)
for more.
Sublime Text[](https://gohugo.io/tools/editors/#sublime-text)
--------------------------------------------------------------
[Hugofy](https://github.com/akmittal/Hugofy)
[](https://gohugo.io/tools/editors/#hugofy-1)
Hugofy is a plugin for Sublime Text 3 to make life easier to use Hugo static site generator.
[Hugo Snippets](https://packagecontrol.io/packages/Hugo%20Snippets)
[](https://gohugo.io/tools/editors/#hugo-snippets)
Hugo Snippets is a useful plugin for adding automatic snippets to Sublime Text 3.
Vim[](https://gohugo.io/tools/editors/#vim)
--------------------------------------------
[Vim Hugo Helper](https://github.com/robertbasic/vim-hugo-helper)
[](https://gohugo.io/tools/editors/#vim-hugo-helper)
A small Vim plugin that facilitates authoring pages and blog posts with Hugo.
[vim-hugo](https://github.com/phelipetls/vim-hugo)
[](https://gohugo.io/tools/editors/#vim-hugo)
A Vim plugin with syntax highlighting for templates and a few other features.
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/tools/editors.md)
---
# Host and deploy
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Deploy with hugo\
\
Deploy your site with the hugo CLI.](https://gohugo.io/host-and-deploy/deploy-with-hugo-deploy/)
[### Deploy with rclone\
\
Deploy your site with the rclone CLI.](https://gohugo.io/host-and-deploy/deploy-with-rclone/)
[### Deploy with rsync\
\
Deploy your site with the rsync CLI.](https://gohugo.io/host-and-deploy/deploy-with-rsync/)
[### Host on AWS Amplify\
\
Host your site on AWS Amplify.](https://gohugo.io/host-and-deploy/host-on-aws-amplify/)
[### Host on Azure Static Web Apps\
\
Host your site on Azure Static Web Apps.](https://gohugo.io/host-and-deploy/host-on-azure-static-web-apps/)
[### Host on Cloudflare\
\
Host your site on Cloudflare.](https://gohugo.io/host-and-deploy/host-on-cloudflare/)
[### Host on Firebase\
\
Host your site on Firebase.](https://gohugo.io/host-and-deploy/host-on-firebase/)
[### Host on GitHub Pages\
\
Host your site on GitHub Pages.](https://gohugo.io/host-and-deploy/host-on-github-pages/)
[### Host on GitLab Pages\
\
Host your site on GitLab Pages.](https://gohugo.io/host-and-deploy/host-on-gitlab-pages/)
[### Host on Netlify\
\
Host your site on Netlify.](https://gohugo.io/host-and-deploy/host-on-netlify/)
[### Host on Render\
\
Host your site on Render.](https://gohugo.io/host-and-deploy/host-on-render/)
[### Host on SourceHut Pages\
\
Host your site on SourceHut Pages.](https://gohugo.io/host-and-deploy/host-on-sourcehut-pages/)
[### Host on Vercel\
\
Host your site on Vercel.](https://gohugo.io/host-and-deploy/host-on-vercel/)
---
# Hugo Modules
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Introduction\
\
A brief introduction to Hugo Modules.](https://gohugo.io/hugo-modules/introduction/)
[### Use Hugo Modules\
\
Use modules to manage the content, layout, presentation, and behavior of your site.](https://gohugo.io/hugo-modules/use-modules/)
[### Theme components\
\
Hugo provides advanced theming support with theme components.](https://gohugo.io/hugo-modules/theme-components/)
---
# Hugo Pipes
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Introduction\
\
Hugo Pipes is Hugo's asset processing set of functions.](https://gohugo.io/hugo-pipes/introduction/)
[### Asset minification\
\
Minify a given resource.](https://gohugo.io/hugo-pipes/minification/)
[### Concatenating assets\
\
Bundle any number of assets into one resource.](https://gohugo.io/hugo-pipes/bundling/)
[### Fingerprinting and SRI hashing\
\
Cryptographically hash the content of the given resource.](https://gohugo.io/hugo-pipes/fingerprint/)
[### JavaScript building\
\
Bundle, transpile, tree shake, code split, and minify JavaScript resources.](https://gohugo.io/hugo-pipes/js/)
[### PostCSS\
\
Process the given resource with PostCSS using any PostCSS plugin.](https://gohugo.io/hugo-pipes/postcss/)
[### PostProcess\
\
Process the given resource after the build.](https://gohugo.io/hugo-pipes/postprocess/)
[### Resource from string\
\
Create a resource from a string.](https://gohugo.io/hugo-pipes/resource-from-string/)
[### Resource from template\
\
Create a resource from a Go template, parsed and executed with the given context.](https://gohugo.io/hugo-pipes/resource-from-template/)
[### Transpile Sass to CSS\
\
Transpile Sass to CSS.](https://gohugo.io/hugo-pipes/transpile-sass-to-css/)
---
# Installation
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### macOS\
\
Install Hugo on macOS.](https://gohugo.io/installation/macos/)
[### Linux\
\
Install Hugo on Linux.](https://gohugo.io/installation/linux/)
[### Windows\
\
Install Hugo on Windows.](https://gohugo.io/installation/windows/)
[### BSD\
\
Install Hugo on BSD derivatives.](https://gohugo.io/installation/bsd/)
---
# Introduction
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hugo is a static site generator written in Go, optimized for speed and designed for flexibility.
Hugo is a [static site generator](https://en.wikipedia.org/wiki/Static_site_generator)
written in [Go](https://go.dev/)
, optimized for speed and designed for flexibility. With its advanced templating system and fast asset pipelines, Hugo renders a complete site in seconds, often less.
Due to its flexible framework, multilingual support, and powerful taxonomy system, Hugo is widely used to create:
* Corporate, government, nonprofit, education, news, event, and project sites
* Documentation sites
* Image portfolios
* Landing pages
* Business, professional, and personal blogs
* Resumes and CVs
Use Hugo’s embedded web server during development to instantly see changes to content, structure, behavior, and presentation. Then deploy the site to your host, or push changes to your Git provider for automated builds and deployment.
And with [Hugo Modules](https://gohugo.io/hugo-modules/)
, you can share content, assets, data, translations, themes, templates, and configuration with other projects via public or private Git repositories.
Learn more about Hugo’s [features](https://gohugo.io/about/features/)
, [privacy protections](https://gohugo.io/configuration/privacy/)
, and [security model](https://gohugo.io/about/security/)
.
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/about/introduction.md)
---
# Introduction
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

A brief introduction to Hugo Modules.
Hugo uses modules as its fundamental organizational units. A module can be a full Hugo project or a smaller, reusable piece providing one or more of Hugo’s seven component types: static files, content, layouts, data, assets, internationalization (i18n) resources, and archetypes.
Modules are combinable in any arrangement, and external directories (including those from non-Hugo projects) can be mounted, effectively creating a single, unified file system.
Some example projects:
[https://github.com/bep/docuapi](https://github.com/bep/docuapi)
A theme that has been ported to Hugo Modules while testing this feature. It is a good example of a non-Hugo-project mounted into Hugo’s directory structure.
[https://github.com/bep/my-modular-site](https://github.com/bep/my-modular-site)
A simple site used for testing.
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/hugo-modules/introduction.md)
---
# News
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[February 25, 2026\
\
### Release v0.157.0](https://github.com/gohugoio/hugo/releases/tag/v0.157.0)
[February 18, 2026\
\
### Release v0.156.0](https://github.com/gohugoio/hugo/releases/tag/v0.156.0)
[February 8, 2026\
\
### Release v0.155.3](https://github.com/gohugoio/hugo/releases/tag/v0.155.3)
[February 2, 2026\
\
### Release v0.155.2](https://github.com/gohugoio/hugo/releases/tag/v0.155.2)
[January 30, 2026\
\
### Release v0.155.1](https://github.com/gohugoio/hugo/releases/tag/v0.155.1)
[January 28, 2026\
\
### Release v0.155.0](https://github.com/gohugoio/hugo/releases/tag/v0.155.0)
[January 11, 2026\
\
### Release v0.154.5](https://github.com/gohugoio/hugo/releases/tag/v0.154.5)
[January 10, 2026\
\
### Release v0.154.4](https://github.com/gohugoio/hugo/releases/tag/v0.154.4)
[January 6, 2026\
\
### Release v0.154.3](https://github.com/gohugoio/hugo/releases/tag/v0.154.3)
[January 2, 2026\
\
### Release v0.154.2](https://github.com/gohugoio/hugo/releases/tag/v0.154.2)
[January 1, 2026\
\
### Release v0.154.1](https://github.com/gohugoio/hugo/releases/tag/v0.154.1)
[December 31, 2025\
\
### Release v0.154.0](https://github.com/gohugoio/hugo/releases/tag/v0.154.0)
[December 30, 2025\
\
### Release v0.153.5](https://github.com/gohugoio/hugo/releases/tag/v0.153.5)
[December 28, 2025\
\
### Release v0.153.4](https://github.com/gohugoio/hugo/releases/tag/v0.153.4)
[December 26, 2025\
\
### Release v0.153.3](https://github.com/gohugoio/hugo/releases/tag/v0.153.3)
[December 22, 2025\
\
### Release v0.153.2](https://github.com/gohugoio/hugo/releases/tag/v0.153.2)
[December 20, 2025\
\
### Release v0.153.1](https://github.com/gohugoio/hugo/releases/tag/v0.153.1)
[December 19, 2025\
\
### Release v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
[October 24, 2025\
\
### Release v0.152.2](https://github.com/gohugoio/hugo/releases/tag/v0.152.2)
[October 22, 2025\
\
### Release v0.152.1](https://github.com/gohugoio/hugo/releases/tag/v0.152.1)
[October 21, 2025\
\
### Release v0.152.0](https://github.com/gohugoio/hugo/releases/tag/v0.152.0)
[October 16, 2025\
\
### Release v0.151.2](https://github.com/gohugoio/hugo/releases/tag/v0.151.2)
[October 15, 2025\
\
### Release v0.151.1](https://github.com/gohugoio/hugo/releases/tag/v0.151.1)
[October 2, 2025\
\
### Release v0.151.0](https://github.com/gohugoio/hugo/releases/tag/v0.151.0)
---
# Quick reference guides
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Emojis\
\
Include emoji shortcodes in your Markdown or templates.](https://gohugo.io/quick-reference/emojis/)
[### Functions\
\
A quick reference guide to Hugo's functions, grouped by namespace. Aliases, if any, appear in parentheses to the right of the function name.](https://gohugo.io/quick-reference/functions/)
[### Glob patterns\
\
A quick reference guide to glob pattern syntax and matching rules for wildcards, character sets, and delimiters, featuring illustrative examples.](https://gohugo.io/quick-reference/glob-patterns/)
[### Glossary\
\
Terms commonly used throughout the documentation.](https://gohugo.io/quick-reference/glossary/)
[### Methods\
\
A quick reference guide to Hugo's methods, grouped by object.](https://gohugo.io/quick-reference/methods/)
[### Page collections\
\
A quick reference guide to Hugo's page collections.](https://gohugo.io/quick-reference/page-collections/)
[### Syntax highlighting styles\
\
Highlight code examples using one of these styles.](https://gohugo.io/quick-reference/syntax-highlighting-styles/)
---
# Render hooks
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Introduction\
\
An introduction to Hugo's render hooks.](https://gohugo.io/render-hooks/introduction/)
[### Blockquotes\
\
Create blockquote render hook templates to override the rendering of Markdown blockquotes to HTML.](https://gohugo.io/render-hooks/blockquotes/)
[### Code blocks\
\
Create code block render hook templates to override the rendering of Markdown code blocks to HTML.](https://gohugo.io/render-hooks/code-blocks/)
[### Headings\
\
Create heading render hook templates to override the rendering of Markdown headings to HTML.](https://gohugo.io/render-hooks/headings/)
[### Images\
\
Create image render hook templates to override the rendering of Markdown images to HTML.](https://gohugo.io/render-hooks/images/)
[### Links\
\
Create a link render hook to override the rendering of Markdown links to HTML.](https://gohugo.io/render-hooks/links/)
[### Passthrough\
\
Create passthrough render hook templates to override the rendering of text snippets captured by the Goldmark Passthrough extension.](https://gohugo.io/render-hooks/passthrough/)
[### Tables\
\
Create table render hook templates to override the rendering of Markdown tables to HTML.](https://gohugo.io/render-hooks/tables/)
---
# Introduction
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

An introduction to Hugo’s render hooks.
When rendering Markdown to HTML, render hooks override the conversion. Each render hook is a template, with one template for each supported element type:
* [Blockquotes](https://gohugo.io/render-hooks/blockquotes/)
* [Code blocks](https://gohugo.io/render-hooks/code-blocks/)
* [Headings](https://gohugo.io/render-hooks/headings/)
* [Images](https://gohugo.io/render-hooks/images/)
* [Links](https://gohugo.io/render-hooks/links/)
* [Passthrough elements](https://gohugo.io/render-hooks/passthrough/)
* [Tables](https://gohugo.io/render-hooks/tables/)
Hugo supports multiple [content formats](https://gohugo.io/content-management/formats/)
including Markdown, HTML, AsciiDoc, Emacs Org Mode, Pandoc, and reStructuredText.
The render hook capability is limited to Markdown. You cannot create render hooks for the other content formats.
For example, consider this Markdown:
[Hugo](https://gohugo.io)

Without link or image render hooks, the example above is rendered to:
Each render hook is a template, with one template for each supported element type:
layouts/
└── _markup/
├── render-blockquote.html
├── render-codeblock.html
├── render-heading.html
├── render-image.html
├── render-link.html
├── render-passthrough.html
└── render-table.html
The template lookup order allows you to create different render hooks for each page [type](https://gohugo.io/quick-reference/glossary/#type)
, [kind](https://gohugo.io/quick-reference/glossary/#kind)
, language, and [output format](https://gohugo.io/quick-reference/glossary/#output-format)
. For example:
layouts/
├── _markup/
│ ├── render-link.html
│ └── render-link.rss.xml
├── books/
│ └── _markup/
│ ├── render-link.html
│ └── render-link.rss.xml
└── films/
└── _markup/
├── render-link.html
└── render-link.rss.xml
The remaining pages in this section describe each type of render hook, including examples and the context received by each template.
* * *
Last updated: July 7, 2025 : [Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45' (079671b41)](https://github.com/gohugoio/hugoDocs/commit/079671b41b9395f2c2b48879f14d3f09d69a63dc)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/render-hooks/introduction.md)
---
# Quick start
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Create your first Hugo project.
In this tutorial you will:
1. Create a project
2. Add content
3. Configure the project
4. Publish the project
Prerequisites
-------------
Before you begin this tutorial you must:
1. [Install Hugo](https://gohugo.io/installation/)
(extended or extended/deploy edition, v0.156.0 or later)
2. [Install Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
You must also be comfortable working from the command line.
Create a project
----------------
### Commands
**If you are a Windows user:**
* Do not use the Command Prompt
* Do not use Windows PowerShell
* Run these commands from [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows)
or a Linux terminal such as WSL or Git > Bash
PowerShell and Windows PowerShell [are different applications](https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.3)
.
Verify that you have installed Hugo v0.156.0 or later.
hugo version
Run these commands to create a Hugo project with the [Ananke](https://github.com/theNewDynamic/gohugo-theme-ananke)
theme. The next section provides an explanation of each command.
hugo new project quickstart
cd quickstart
git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
echo "theme = 'ananke'" >> hugo.toml
hugo server
View your project at the URL displayed in your terminal. Press `Ctrl + C` to stop Hugo’s development server.
### Explanation of commands
Create the [project skeleton](https://gohugo.io/getting-started/directory-structure/#project-skeleton)
for your project in the `quickstart` directory.
hugo new project quickstart
Change the current directory to the root of your project.
cd quickstart
Initialize an empty Git repository in the current directory.
git init
Clone the [Ananke](https://github.com/theNewDynamic/gohugo-theme-ananke)
theme into the `themes` directory, adding it to your project as a [Git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
.
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
Append a line to your project configuration file, indicating the current theme.
echo "theme = 'ananke'" >> hugo.toml
Start Hugo’s development server.
hugo server
Press `Ctrl + C` to stop Hugo’s development server.
Add content
-----------
Add a new page to your project.
hugo new content content/posts/my-first-post.md
Hugo created the file in the `content/posts` directory. Open the file with your editor.
+++
title = 'My First Post'
date = 2024-01-14T07:07:07+01:00
draft = true
+++
Notice the `draft` value in the [front matter](https://gohugo.io/content-management/front-matter/)
is `true`. By default, Hugo does not publish draft content when you build the project. Learn more about [draft, future, and expired content](https://gohugo.io/getting-started/usage/#draft-future-and-expired-content)
.
Add some [Markdown](https://daringfireball.net/projects/markdown)
to the body of the post, but do not change the `draft` value.
+++
title = 'My First Post'
date = 2024-01-14T07:07:07+01:00
draft = true
+++
## Introduction
This is **bold** text, and this is *emphasized* text.
Visit the [Hugo](https://gohugo.io) website!
Save the file, then start Hugo’s development server. You can run either of the following commands to include draft content.
hugo server --buildDrafts
hugo server -D
View your project at the URL displayed in your terminal. Keep the development server running as you continue to add and change content.
When satisfied with your new content, set the front matter `draft` parameter to `false`.
Hugo’s rendering engine conforms to the CommonMark [specification](https://spec.commonmark.org/)
for Markdown. The CommonMark organization provides a useful [live testing tool](https://spec.commonmark.org/dingus/)
powered by the reference implementation.
Configure the project
---------------------
With your editor, open your [project configuration](https://gohugo.io/configuration/)
file (`hugo.toml`) in the root of your project.
baseURL = 'https://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Project'
theme = 'ananke'
Make the following changes:
1. Set the `baseURL` for your project. This value must begin with the protocol and end with a slash, as shown above.
2. Set the `languageCode` to your locale.
3. Set the `title` for your project.
Start Hugo’s development server to see your changes, remembering to include draft content.
hugo server -D
Most theme authors provide configuration guidelines and options. Make sure to visit your theme’s repository or documentation site for details.
[The New Dynamic](https://www.thenewdynamic.com/)
, authors of the Ananke theme, provide [documentation](https://github.com/theNewDynamic/gohugo-theme-ananke#readme)
for configuration and usage. They also provide a [demonstration site](https://gohugo-ananke-theme-demo.netlify.app/)
.
Publish the project
-------------------
In this step you will _publish_ your project, but you will not _deploy_ it.
When you publish your project, Hugo renders all build artifacts to the `public` directory in the root of your project. This includes the HTML files for every site, along with assets such as images, CSS, and JavaScript. The command is simple.
hugo
To learn how to _deploy_ your project, see the [host and deploy](https://gohugo.io/host-and-deploy/)
section.
Ask for help
------------
Hugo’s [forum](https://discourse.gohugo.io/)
is an active community of users and developers who answer questions, share knowledge, and provide examples. A quick search of over 20,000 topics will often answer your question. Please be sure to read about [requesting help](https://discourse.gohugo.io/t/requesting-help/9132)
before asking your first question.
Other resources
---------------
For other resources to help you learn Hugo, including books and video tutorials, see the [external learning resources](https://gohugo.io/getting-started/external-learning-resources/)
page.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/getting-started/quick-start.md)
---
# Methods
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Duration\
\
Use these methods with a time.Duration value.](https://gohugo.io/methods/duration/)
[### Menu\
\
Use these methods when ranging through menu entries.](https://gohugo.io/methods/menu/)
[### Menu entry\
\
Use these methods in your menu templates.](https://gohugo.io/methods/menu-entry/)
[### Output format\
\
Use these methods with an OutputFormat object.](https://gohugo.io/methods/output-format/)
[### Page\
\
Use these methods with a Page object.](https://gohugo.io/methods/page/)
[### Pager\
\
Use these methods with a Pager object when building navigation for a paginated list page.](https://gohugo.io/methods/pager/)
[### Pages\
\
Use these methods with a collection of Page objects.](https://gohugo.io/methods/pages/)
[### Resource\
\
Use these methods with a global, page, or remote Resource object.](https://gohugo.io/methods/resource/)
[### Shortcode\
\
Use these methods in your shortcode templates.](https://gohugo.io/methods/shortcode/)
[### Site\
\
Use these methods with a Site object.](https://gohugo.io/methods/site/)
[### Taxonomy\
\
Use these methods with a Taxonomy object.](https://gohugo.io/methods/taxonomy/)
[### Time\
\
Use these methods with a time.Time value.](https://gohugo.io/methods/time/)
---
# macOS
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Install Hugo on macOS.
Editions
--------
Hugo offers a standard edition with core features, plus extended and extended/deploy editions with more. Use the standard edition unless you need the features below.
| Feature | extended edition | extended/deploy edition |
| --- | --- | --- |
| [Transpile Sass to CSS](https://gohugo.io/functions/css/sass/) via embedded LibSass. Note that embedded LibSass was deprecated in v0.153.0 and will be removed in a future release. Use the [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass) transpiler instead, which is compatible with any edition. | ✔️ | ✔️ |
| Deploy your site directly to a Google Cloud Storage bucket, an AWS S3 bucket, or an Azure Storage container. See [details](https://gohugo.io/host-and-deploy/deploy-with-hugo-deploy/) . | ❌ | ✔️ |
Prerequisites
-------------
Although not required in all cases, [Git](https://git-scm.com/)
, [Go](https://go.dev/)
, and [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass)
are commonly used when working with Hugo.
Git is required to:
* Build Hugo from source
* Use the [Hugo Modules](https://gohugo.io/hugo-modules/)
feature
* Install a theme as a Git submodule
* Access [commit information](https://gohugo.io/methods/page/gitinfo/)
from a local Git repository
* Host your site on [CI/CD](https://gohugo.io/quick-reference/glossary/#cicd)
platforms such as [Cloudflare](https://gohugo.io/host-and-deploy/host-on-cloudflare/)
, [GitHub Pages](https://gohugo.io/host-and-deploy/host-on-github-pages/)
, [GitLab Pages](https://gohugo.io/host-and-deploy/host-on-gitlab-pages/)
, [Netlify](https://gohugo.io/host-and-deploy/host-on-netlify/)
, [Render](https://gohugo.io/host-and-deploy/host-on-render/)
, or [Vercel](https://gohugo.io/host-and-deploy/host-on-vercel/)
Go is required to:
* Build Hugo from source
* Use the Hugo Modules feature
Dart Sass is required to transpile Sass to CSS when using the latest features of the Sass language.
Please refer to the relevant documentation for installation instructions:
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [Go](https://go.dev/doc/install)
* [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass)
Prebuilt binaries
-----------------
Prebuilt binaries are available for a variety of operating systems and architectures. Visit the [latest release](https://github.com/gohugoio/hugo/releases/latest)
page, and scroll down to the Assets section.
1. Download the archive for the desired edition, operating system, and architecture
2. Extract the archive
3. Move the executable to the desired directory
4. Add this directory to the PATH environment variable
5. Verify that you have _execute_ permission on the file
Please consult your operating system documentation if you need help setting file permissions or modifying your PATH environment variable.
If you do not see a prebuilt binary for the desired edition, operating system, and architecture, install Hugo using one of the methods described below.
Package managers
----------------
### Homebrew
[Homebrew](https://brew.sh/)
is a free and open-source package manager for macOS and Linux. To install the extended/deploy edition of Hugo:
brew install hugo
### MacPorts
[MacPorts](https://www.macports.org/)
is a free and open-source package manager for macOS. To install the extended edition of Hugo:
sudo port install hugo
Build from source
-----------------
To build the extended or extended/deploy edition from source you must:
1. Install [Git](https://git-scm.com/)
2. Install [Go](https://go.dev/)
version 1.24.0 or later
3. Install a C compiler, either [GCC](https://gcc.gnu.org/)
or [Clang](https://clang.llvm.org/)
4. Update your `PATH` environment variable as described in the [Go documentation](https://go.dev/doc/code#Command)
> The install directory is controlled by the `GOPATH` and `GOBIN` environment variables. If `GOBIN` is set, binaries are installed to that directory. If `GOPATH` is set, binaries are installed to the bin subdirectory of the first directory in the `GOPATH` list. Otherwise, binaries are installed to the bin subdirectory of the default `GOPATH` (`$HOME/go` or `%USERPROFILE%\go`).
To build the standard edition:
go install github.com/gohugoio/hugo@latest
To build the extended edition:
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest
To build the extended/deploy edition:
CGO_ENABLED=1 go install -tags extended,withdeploy github.com/gohugoio/hugo@latest
Comparison
----------
| | Prebuilt binaries | Package managers | Build from source |
| --- | --- | --- | --- |
| Easy to install? | ✔️ | ✔️ | ✔️ |
| Easy to upgrade? | ✔️ | ✔️ | ✔️ |
| Easy to downgrade? | ✔️ | ✔️ [1](https://gohugo.io/installation/macos/#fn:1) | ✔️ |
| Automatic updates? | ❌ | ❌ [2](https://gohugo.io/installation/macos/#fn:2) | ❌ |
| Latest version available? | ✔️ | ✔️ | ✔️ |
* * *
1. Easy if a previous version is still installed. [↩︎](https://gohugo.io/installation/macos/#fnref:1)
2. Possible but requires advanced configuration. [↩︎](https://gohugo.io/installation/macos/#fnref:2)
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/installation/macos.md)
---
# Shortcodes
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Details\
\
Insert an HTML details element into your content using the details shortcode.](https://gohugo.io/shortcodes/details/)
[### Figure\
\
Insert an HTML figure element into your content using the figure shortcode.](https://gohugo.io/shortcodes/figure/)
[### Highlight\
\
Insert syntax-highlighted code into your content using the highlight shortcode.](https://gohugo.io/shortcodes/highlight/)
[### Instagram\
\
Embed an Instagram post in your content using the instagram shortcode.](https://gohugo.io/shortcodes/instagram/)
[### Param\
\
Insert a parameter from front matter or your project configuration into your content using the param shortcode.](https://gohugo.io/shortcodes/param/)
[### QR\
\
Insert a QR code into your content using the qr shortcode.](https://gohugo.io/shortcodes/qr/)
[### Ref\
\
Insert a permalink to the given page reference using the ref shortcode.](https://gohugo.io/shortcodes/ref/)
[### Relref\
\
Insert a relative permalink to the given page reference using the relref shortcode.](https://gohugo.io/shortcodes/relref/)
[### Vimeo\
\
Embed a Vimeo video in your content using the vimeo shortcode.](https://gohugo.io/shortcodes/vimeo/)
[### X\
\
Embed an X post in your content using the x shortcode.](https://gohugo.io/shortcodes/x/)
[### YouTube\
\
Embed a YouTube video in your content using the youtube shortcode.](https://gohugo.io/shortcodes/youtube/)
---
# Hugo Pipes
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hugo Pipes is Hugo’s asset processing set of functions.
Find resources in assets
------------------------
This is about global and remote resources.
global resource
A file within the `assets` directory, or within any directory [mounted](https://gohugo.io/configuration/module/#mounts)
to the `assets` directory.
remote resource
A file on a remote server, accessible via HTTP or HTTPS.
For `.Page` scoped resources, see the [page resources](https://gohugo.io/content-management/page-resources/)
section.
Get a resource
--------------
In order to process an asset with Hugo Pipes, it must be retrieved as a resource.
For global resources, use:
* [`resources.ByType`](https://gohugo.io/functions/resources/bytype/)
* [`resources.Get`](https://gohugo.io/functions/resources/get/)
* [`resources.GetMatch`](https://gohugo.io/functions/resources/getmatch/)
* [`resources.Match`](https://gohugo.io/functions/resources/match/)
For remote resources, use:
* [`resources.GetRemote`](https://gohugo.io/functions/resources/getremote/)
See the [GoDoc Page](https://pkg.go.dev/github.com/gohugoio/hugo/tpl/resources)
for the `resources` package for an up to date overview of all template functions in this namespace.
Copy a resource
---------------
See the [`resources.Copy`](https://gohugo.io/functions/resources/copy/)
function.
Asset directory
---------------
Asset files must be stored in the asset directory. This is `assets` by default, but can be configured via the configuration file’s `assetDir` key.
Asset publishing
----------------
Hugo publishes assets to the `publishDir` (typically `public`) when you invoke `.Permalink`, `.RelPermalink`, or `.Publish`. You can use `.Content` to inline the asset.
Go Pipes
--------
For improved readability, the Hugo Pipes examples of this documentation will be written using [Go Pipes](https://gohugo.io/templates/introduction/#pipes)
:
{{ $style := resources.Get "sass/main.scss" | css.Sass | resources.Minify | resources.Fingerprint }}
Caching
-------
Hugo Pipes invocations are cached based on the entire _pipe chain_.
An example of a pipe chain is:
{{ $mainJs := resources.Get "js/main.js" | js.Build "main.js" | minify | fingerprint }}
The pipe chain is only invoked the first time it is encountered in a site build, and results are otherwise loaded from cache. As such, Hugo Pipes can be used in templates which are executed thousands or millions of times without negatively impacting the build performance.
* * *
Last updated: August 23, 2025 : [Merge commit 'bfa74537929f409fca841540b971125b7678963a' (6c911d1e5)](https://github.com/gohugoio/hugoDocs/commit/6c911d1e52fb9c8065c079820327f4b0e37529d4)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/hugo-pipes/introduction.md)
---
# Troubleshooting
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Audit\
\
Run this audit before deploying your production site.](https://gohugo.io/troubleshooting/audit/)
[### Deprecation\
\
The Hugo project follows a formal and consistent process to deprecate functions, methods, and configuration settings.](https://gohugo.io/troubleshooting/deprecation/)
[### FAQs\
\
These questions are frequently asked by new users.](https://gohugo.io/troubleshooting/faq/)
[### Inspection\
\
Use template functions to inspect values and data structures.](https://gohugo.io/troubleshooting/inspection/)
[### Logging\
\
Enable logging to inspect events while building your project.](https://gohugo.io/troubleshooting/logging/)
[### Performance\
\
Tools and suggestions for evaluating and improving performance.](https://gohugo.io/troubleshooting/performance/)
---
# Introduction
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Configure your site using files, directories, and environment variables.
Sensible defaults
-----------------
Hugo offers many configuration options, but its defaults are often sufficient. A new site requires only these settings:
baseURL: https://example.org/
languageCode: en-us
title: My New Hugo Site
baseURL = 'https://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
{
"baseURL": "https://example.org/",
"languageCode": "en-us",
"title": "My New Hugo Site"
}
Only define settings that deviate from the defaults. A smaller configuration file is easier to read, understand, and debug. Keep your configuration concise.
The best configuration file is a short configuration file.
Configuration file
------------------
Create a project configuration file in the root of your project directory, naming it `hugo.toml`, `hugo.yaml`, or `hugo.json`, with that order of precedence.
my-project/
└── hugo.toml
For versions v0.109.0 and earlier, the project configuration file was named `config`. While you can still use this name, it’s recommended to switch to the newer naming convention, `hugo`.
A simple example:
baseURL: https://example.org/
languageCode: en-us
params:
contact:
email: info@example.org
phone: +1 202-555-1212
subtitle: The Best Widgets on Earth
title: ABC Widgets, Inc.
baseURL = 'https://example.org/'
languageCode = 'en-us'
title = 'ABC Widgets, Inc.'
[params]
subtitle = 'The Best Widgets on Earth'
[params.contact]
email = 'info@example.org'
phone = '+1 202-555-1212'
{
"baseURL": "https://example.org/",
"languageCode": "en-us",
"params": {
"contact": {
"email": "info@example.org",
"phone": "+1 202-555-1212"
},
"subtitle": "The Best Widgets on Earth"
},
"title": "ABC Widgets, Inc."
}
To use a different configuration file when building your project, use the `--config` flag:
hugo build --config other.toml
Combine two or more configuration files, with left-to-right precedence:
hugo build --config a.toml,b.yaml,c.json
See the specifications for each file format: [TOML](https://toml.io/en/latest)
, [YAML](https://yaml.org/spec/)
, and [JSON](https://datatracker.ietf.org/doc/html/rfc7159)
.
Configuration directory
-----------------------
Instead of a single project configuration file, split your configuration by [environment](https://gohugo.io/quick-reference/glossary/#environment)
, root configuration key, and language. For example:
my-project/
└── config/
├── _default/
│ ├── hugo.toml
│ ├── menus.en.toml
│ ├── menus.de.toml
│ └── params.toml
└── production/
└── params.toml
The root configuration keys are [`HTTPCache`](https://gohugo.io/configuration/http-cache/)
, [`build`](https://gohugo.io/configuration/build/)
, [`caches`](https://gohugo.io/configuration/caches/)
, [`contentTypes`](https://gohugo.io/configuration/content-types/)
, [`deployment`](https://gohugo.io/configuration/deployment/)
, [`frontmatter`](https://gohugo.io/configuration/front-matter/)
, [`imaging`](https://gohugo.io/configuration/imaging/)
, [`languages`](https://gohugo.io/configuration/languages/)
, [`markup`](https://gohugo.io/configuration/markup/)
, [`mediaTypes`](https://gohugo.io/configuration/media-types/)
, [`menus`](https://gohugo.io/configuration/menus/)
, [`minify`](https://gohugo.io/configuration/minify/)
, [`module`](https://gohugo.io/configuration/module/)
, [`outputFormats`](https://gohugo.io/configuration/output-formats/)
, [`outputs`](https://gohugo.io/configuration/outputs/)
, [`page`](https://gohugo.io/configuration/page/)
, [`pagination`](https://gohugo.io/configuration/pagination/)
, [`params`](https://gohugo.io/configuration/params/)
, [`permalinks`](https://gohugo.io/configuration/permalinks/)
, [`privacy`](https://gohugo.io/configuration/privacy/)
, [`related`](https://gohugo.io/configuration/related-content/)
, [`roles`](https://gohugo.io/configuration/roles/)
, [`security`](https://gohugo.io/configuration/security/)
, [`segments`](https://gohugo.io/configuration/segments/)
, [`server`](https://gohugo.io/configuration/server/)
, [`services`](https://gohugo.io/configuration/services/)
, [`sitemap`](https://gohugo.io/configuration/sitemap/)
, [`taxonomies`](https://gohugo.io/configuration/taxonomies/)
, [`uglyURLs`](https://gohugo.io/configuration/ugly-urls/)
, and [`versions`](https://gohugo.io/configuration/versions/)
.
You must define `cascade` tables in the root configuration file. You cannot define `cascade` tables in a dedicated file. See issue [#12899](https://github.com/gohugoio/hugo/issues/12899)
for details.
### Omit the root key
When splitting the configuration by root key, omit the root key in the component file. For example, these are equivalent:
params:
foo: bar
[params]
foo = 'bar'
{
"params": {
"foo": "bar"
}
}
foo: bar
foo = 'bar'
{
"foo": "bar"
}
### Recursive parsing
Hugo parses the `config` directory recursively, allowing you to organize the files into subdirectories. For example:
my-project/
└── config/
└── _default/
├── navigation/
│ ├── menus.de.toml
│ └── menus.en.toml
└── hugo.toml
### Example
my-project/
└── config/
├── _default/
│ ├── hugo.toml
│ ├── menus.en.toml
│ ├── menus.de.toml
│ └── params.toml
├── production/
│ ├── hugo.toml
│ └── params.toml
└── staging/
├── hugo.toml
└── params.toml
Considering the structure above, when running `hugo build --environment staging`, Hugo will use every setting from `config/_default` and merge `staging`’s on top of those.
Let’s take an example to understand this better. Let’s say you are using Google Analytics for your website. This requires you to specify a [Google tag ID](https://support.google.com/tagmanager/answer/12326985?hl=en)
in your project configuration:
services:
googleAnalytics:
ID: G-XXXXXXXXX
[services]
[services.googleAnalytics]
ID = 'G-XXXXXXXXX'
{
"services": {
"googleAnalytics": {
"ID": "G-XXXXXXXXX"
}
}
}
Now consider the following scenario:
1. You don’t want to load the analytics code when running `hugo server`.
2. You want to use different Google tag IDs for your production and staging environments. For example:
* `G-PPPPPPPPP` for production
* `G-SSSSSSSSS` for staging
To satisfy these requirements, configure your site as follows:
1. `config/_default/hugo.toml`
* Exclude the `services.googleAnalytics` section. This will prevent loading of the analytics code when you run `hugo server`.
* By default, Hugo sets its `environment` to `development` when running `hugo server`. In the absence of a `config/development` directory, Hugo uses the `config/_default` directory.
2. `config/production/hugo.toml`
* Include this section only:
services:
googleAnalytics:
ID: G-PPPPPPPPP
[services]
[services.googleAnalytics]
ID = 'G-PPPPPPPPP'
{
"services": {
"googleAnalytics": {
"ID": "G-PPPPPPPPP"
}
}
}
* You do not need to include other parameters in this file. Include only those parameters that are specific to your production environment. Hugo will merge these parameters with the default configuration.
* By default, Hugo sets its `environment` to `production` when running `hugo build`. The analytics code will use the `G-PPPPPPPPP` tag ID.
3. `config/staging/hugo.toml`
* Include this section only:
services:
googleAnalytics:
ID: G-SSSSSSSSS
[services]
[services.googleAnalytics]
ID = 'G-SSSSSSSSS'
{
"services": {
"googleAnalytics": {
"ID": "G-SSSSSSSSS"
}
}
}
* You do not need to include other parameters in this file. Include only those parameters that are specific to your staging environment. Hugo will merge these parameters with the default configuration.
* To build your staging site, run `hugo build --environment staging`. The analytics code will use the `G-SSSSSSSSS` tag ID.
Merge configuration settings
----------------------------
Hugo merges configuration settings from themes and modules, prioritizing the project’s own settings. Given this simplified project structure with two themes:
project/
├── themes/
│ ├── theme-a/
│ │ └── hugo.toml
│ └── theme-b/
│ └── hugo.toml
└── hugo.toml
and this project-level configuration:
baseURL: https://example.org/
languageCode: en-us
theme:
- theme-a
- theme-b
title: My New Hugo Site
baseURL = 'https://example.org/'
languageCode = 'en-us'
theme = ['theme-a', 'theme-b']
title = 'My New Hugo Site'
{
"baseURL": "https://example.org/",
"languageCode": "en-us",
"theme": [\
"theme-a",\
"theme-b"\
],
"title": "My New Hugo Site"
}
Hugo merges settings in this order:
1. Project configuration (`hugo.toml` in the project root)
2. `theme-a` configuration
3. `theme-b` configuration
The `_merge` setting within each top-level configuration key controls _which_ settings are merged and _how_ they are merged.
The value for `_merge` can be one of:
none
No merge.
shallow
Only add values for new keys.
deep
Add values for new keys, merge existing.
Note that you don’t need to be so verbose as in the default setup below; a `_merge` value higher up will be inherited if not set.
build:
_merge: none
caches:
_merge: none
cascade:
_merge: none
contenttypes:
_merge: none
deployment:
_merge: none
frontmatter:
_merge: none
httpcache:
_merge: none
imaging:
_merge: none
languages:
_merge: none
en:
_merge: none
menus:
_merge: shallow
params:
_merge: deep
markup:
_merge: none
mediatypes:
_merge: shallow
menus:
_merge: shallow
minify:
_merge: none
module:
_merge: none
outputformats:
_merge: shallow
outputs:
_merge: none
page:
_merge: none
pagination:
_merge: none
params:
_merge: deep
permalinks:
_merge: none
privacy:
_merge: none
related:
_merge: none
roles:
_merge: none
security:
_merge: none
segments:
_merge: none
server:
_merge: none
services:
_merge: none
sitemap:
_merge: none
taxonomies:
_merge: none
versions:
_merge: none
[build]
_merge = 'none'
[caches]
_merge = 'none'
[cascade]
_merge = 'none'
[contenttypes]
_merge = 'none'
[deployment]
_merge = 'none'
[frontmatter]
_merge = 'none'
[httpcache]
_merge = 'none'
[imaging]
_merge = 'none'
[languages]
_merge = 'none'
[languages.en]
_merge = 'none'
[languages.en.menus]
_merge = 'shallow'
[languages.en.params]
_merge = 'deep'
[markup]
_merge = 'none'
[mediatypes]
_merge = 'shallow'
[menus]
_merge = 'shallow'
[minify]
_merge = 'none'
[module]
_merge = 'none'
[outputformats]
_merge = 'shallow'
[outputs]
_merge = 'none'
[page]
_merge = 'none'
[pagination]
_merge = 'none'
[params]
_merge = 'deep'
[permalinks]
_merge = 'none'
[privacy]
_merge = 'none'
[related]
_merge = 'none'
[roles]
_merge = 'none'
[security]
_merge = 'none'
[segments]
_merge = 'none'
[server]
_merge = 'none'
[services]
_merge = 'none'
[sitemap]
_merge = 'none'
[taxonomies]
_merge = 'none'
[versions]
_merge = 'none'
{
"build": {
"_merge": "none"
},
"caches": {
"_merge": "none"
},
"cascade": {
"_merge": "none"
},
"contenttypes": {
"_merge": "none"
},
"deployment": {
"_merge": "none"
},
"frontmatter": {
"_merge": "none"
},
"httpcache": {
"_merge": "none"
},
"imaging": {
"_merge": "none"
},
"languages": {
"_merge": "none",
"en": {
"_merge": "none",
"menus": {
"_merge": "shallow"
},
"params": {
"_merge": "deep"
}
}
},
"markup": {
"_merge": "none"
},
"mediatypes": {
"_merge": "shallow"
},
"menus": {
"_merge": "shallow"
},
"minify": {
"_merge": "none"
},
"module": {
"_merge": "none"
},
"outputformats": {
"_merge": "shallow"
},
"outputs": {
"_merge": "none"
},
"page": {
"_merge": "none"
},
"pagination": {
"_merge": "none"
},
"params": {
"_merge": "deep"
},
"permalinks": {
"_merge": "none"
},
"privacy": {
"_merge": "none"
},
"related": {
"_merge": "none"
},
"roles": {
"_merge": "none"
},
"security": {
"_merge": "none"
},
"segments": {
"_merge": "none"
},
"server": {
"_merge": "none"
},
"services": {
"_merge": "none"
},
"sitemap": {
"_merge": "none"
},
"taxonomies": {
"_merge": "none"
},
"versions": {
"_merge": "none"
}
}
Environment variables
---------------------
You can also configure settings using operating system environment variables:
export HUGO_BASEURL=https://example.org/
export HUGO_ENABLEGITINFO=true
export HUGO_ENVIRONMENT=staging
hugo
The above sets the [`baseURL`](https://gohugo.io/configuration/all/#baseurl)
, [`enableGitInfo`](https://gohugo.io/configuration/all/#enablegitinfo)
, and [`environment`](https://gohugo.io/configuration/all/#environment)
configuration options and then builds your site.
An environment variable takes precedence over the values set in the configuration file. This means that if you set a configuration value with both an environment variable and in the configuration file, the value in the environment variable will be used.
Environment variables simplify configuration for [CI/CD](https://gohugo.io/quick-reference/glossary/#cicd)
platforms by allowing you to set values directly within their respective configuration and workflow files.
Environment variable names must be prefixed with `HUGO_`.
To set custom site parameters, prefix the name with `HUGO_PARAMS_`.
For snake\_case variable names, the standard `HUGO_` prefix won’t work. Hugo infers the delimiter from the first character following `HUGO`. This allows for variations like `HUGOxPARAMSxAPI_KEY=abcdefgh` using any [permitted delimiter](https://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html)
.
In addition to configuring standard settings, environment variables may be used to override default values for certain internal settings:
DART\_SASS\_BINARY
(`string`) The absolute path to the Dart Sass executable. By default, Hugo searches for the executable in each of the paths in the `PATH` environment variable.
HUGO\_FILE\_LOG\_FORMAT
(`string`) A format string for the file path, line number, and column number displayed when reporting errors, or when calling the `Position` method from a shortcode or Markdown render hook. Valid tokens are `:file`, `:line`, and `:col`. Default is `:file::line::col`.
HUGO\_MEMORYLIMIT
(`int`) The maximum amount of system memory, in gigabytes, that Hugo can use while rendering your site. Default is 25% of total system memory. Note that `HUGO_MEMORYLIMIT` is a “best effort” setting. Don’t expect Hugo to build a million pages with only 1 GB of memory. You can get more information about how this behaves during the build by running `hugo build --logLevel info` and look for the `dynacache` label.
HUGO\_NUMWORKERMULTIPLIER
(`int`) The number of workers used in parallel processing. Default is the number of logical CPUs.
Current configuration
---------------------
Display the complete project configuration with:
hugo config
Display a specific configuration setting with:
hugo config | grep [key]
Display the configured file mounts with:
hugo config mounts
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/configuration/introduction.md)
---
# Front-end interfaces
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Do you prefer a graphical user interface over a text editor? Give these front-ends a try.
Commercial
----------
[CloudCannon](https://cloudcannon.com/hugo-cms/)
The intuitive Git-based CMS for your Hugo website. CloudCannon syncs changes from your Git repository and pushes content changes back, so your development and content teams are always in sync. Edit all of your content on the page with visual editing, build entire pages with reusable custom components and then publish confidently.
[DatoCMS](https://www.datocms.com/)
DatoCMS is a fully customizable administrative area for your static websites. Use your favorite website generator, let your clients publish new content independently, and the host the site anywhere you like.
[PubCrank](https://www.pubcrank.com/)
PubCrank is a static site editor which lets you define templates for different front matter layouts in your site. This gives writers an easy-to-use visual interface to create and edit content while maintaining the guardrails that the developer has created. PubCrank is free for local editing.
[Sitepins](https://sitepins.com/)
Sitepins is a Git-based CMS built for static site generators like Hugo. It offers a clean visual editor, media management, role-based permissions, shortcode support, and more. To get started, simply connect your GitHub repository, configure your content folders, and start visually editing your Hugo site with Sitepins.
Open-source
-----------
[Decap CMS](https://decapcms.org/)
Decap CMS is an open-source, serverless solution for managing Git based content in static sites, and it works on any platform that can host static sites. A [Hugo/Decap CMS starter](https://github.com/decaporg/one-click-hugo-cms)
is available to get new projects running quickly.
[Quiqr Desktop](https://quiqr.org/)
Quiqr Desktop is a open-source, cross-platform, offline desktop CMS for Hugo with built-in Git functionality for deploying static sites to any hosting server.
[Sveltia CMS](https://github.com/sveltia/sveltia-cms/)
Sveltia CMS is a drop-in replacement for Decap CMS which is built from the ground up with powerful and performant modern UI library Svelte. Sveltia CMS incorporates i18n into every corner of the product, while striving to radically improve UX, performance and productivity.
* * *
Last updated: August 23, 2025 : [Merge commit 'bfa74537929f409fca841540b971125b7678963a' (6c911d1e5)](https://github.com/gohugoio/hugoDocs/commit/6c911d1e52fb9c8065c079820327f4b0e37529d4)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/tools/front-ends.md)
---
# Use Hugo Modules
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Use modules to manage the content, layout, presentation, and behavior of your site.
To work with modules you must install [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
and [Go](https://go.dev/doc/install)
1.18 or later.
Introduction
------------
A _module_ is a packaged combination of [_components_](https://gohugo.io/quick-reference/glossary/#component)
which may include [_archetypes_](https://gohugo.io/quick-reference/glossary/#archetype)
, assets, content, data, templates, [_translation tables_](https://gohugo.io/quick-reference/glossary/#translation-table)
, and static files. A module may be a [_theme_](https://gohugo.io/quick-reference/glossary/#theme)
, a complete project, or a smaller collection of one or more components.
* Modules can be imported in any combination or sequence.
* Module imports are recursive; importing Module A can trigger the import of Module B, and so on.
* Modules can provide configuration files and directories, subject to the constraints described in the [merge configuration settings](https://gohugo.io/configuration/introduction/#merge-configuration-settings)
section of the documentation.
* External directories, including those from non-Hugo projects, can be mounted to create a [unified file system](https://gohugo.io/quick-reference/glossary/#unified-file-system)
.
Import
------
To import a module, first initialize the project itself as a module. For example:
hugo mod init github.com/user/project
This will generate a [`go.mod`](https://go.dev/ref/mod#go-mod-file)
file in the project root.
The module name is a unique identifier rather than a hosting requirement. Using a name like `github.com/user/project` is a common convention but it does not mean you must use Git or host your code on GitHub. You can use any name you like if you do not plan to have others import your project as a module. For example, you could use a simple name such as `my-project` when you run the initialization command.
Then define one or more imports in your project configuration. This contrived example imports three modules, each containing custom shortcodes:
module:
imports:
- path: shortcodes-a
- path: /home/user/shortcodes-b
- path: github.com/user/shortcodes-c
[module]
[[module.imports]]
path = 'shortcodes-a'
[[module.imports]]
path = '/home/user/shortcodes-b'
[[module.imports]]
path = 'github.com/user/shortcodes-c'
{
"module": {
"imports": [\
{\
"path": "shortcodes-a"\
},\
{\
"path": "/home/user/shortcodes-b"\
},\
{\
"path": "github.com/user/shortcodes-c"\
}\
]
}
}
Import precedence is top-down. For example, if `shortcodes-a`, `shortcodes-b`, and `shortcodes-c` each define an `image` shortcode, the `image` shortcode from `shortcodes-a` will take effect.
If multiple modules contain data files or [translation tables](https://gohugo.io/quick-reference/glossary/#translation-table)
with identical paths, the data is deeply merged, following top-down precedence.
When you build your project, Hugo will:
1. Download the modules
2. Cache them for future use
3. Generate a [`go.sum`](https://go.dev/ref/mod#go-sum-files)
file in the project root
See [configuring module imports](https://gohugo.io/configuration/module/#imports)
for details and options.
Update
------
When you import a module, Hugo creates `go.mod` and `go.sum` files in your project root, storing version and checksum data. Clearing the module cache and rebuilding will re-download the originally imported module version, as specified in the `go.mod` file, ensuring consistent builds. Modules can be updated to other versions as needed.
To update a module to the latest version:
hugo mod get -u github.com/user/shortcodes-c
To update a module to a specific version:
hugo mod get -u github.com/user/shortcodes-c@v0.42.0
To update all modules to the latest version:
hugo mod get -u
To recursively update all modules to the latest version:
hugo mod get -u ./...
Tidy
----
To remove unused entries from the `go.mod` and `go.sum` files:
hugo mod tidy
Cache
-----
Hugo caches modules to avoid repeated downloads during site builds. By default, these are stored in the `modules` directory within the [`cacheDir`](https://gohugo.io/configuration/all/#cachedir)
.
To clean the module cache for the current project:
hugo mod clean
To clean the module cache for all projects:
hugo mod clean --all
For details on cache location and eviction, see [configuring file caches](https://gohugo.io/configuration/caches/)
.
Vendor
------
To _vendor_ (verb) in a software context is the process of including the source code of third-party dependencies directly within your own project’s repository, rather than downloading them on the fly from an external package manager.
When you are asked to “vendor the dependencies into the project root,” you are being told to move those external libraries from a temporary cache into a dedicated folder that gets committed to your version control system.
Vendoring a module provides the benefits described above and allows for local inspection of its [components](https://gohugo.io/quick-reference/glossary/#component)
.
hugo mod vendor
This command creates a `_vendor` directory containing copies of all imported modules, used in subsequent builds. Note that:
* The `hugo mod vendor` command can be run from any module tree level.
* Modules within the `themes` directory are not vendored.
* The `--ignoreVendorPaths` flag allows you to exclude vendored modules matching a [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
from specific commands.
Instead of modifying files directly within the `_vendor` directory, override them by creating a corresponding file with the same relative path in your project’s root.
To remove the vendored modules, delete the `_vendor` directory.
Replace
-------
For local module development, use a `replace` directive in `go.mod` pointing to your local directory:
replace github.com/user/module => /home/user/projects/module
With `hugo serve`r running, this change will trigger a configuration reload and add the local directory to the watch list. Alternatively, configure replacements by setting the [`replacements`](https://gohugo.io/configuration/module/#replacements)
parameter in your project configuration.
Workspace
---------
A _workspace_ is a collection of [_modules_](https://gohugo.io/quick-reference/glossary/#module)
on disk.
Workspaces simplify local development of sites with modules. Create a `.work` file to define a workspace, and activate it via the [`workspace`](https://gohugo.io/configuration/module/#workspace)
configuration parameter or the `HUGO_MODULE_WORKSPACE` environment variable.
A `.work` file example:
go 1.24
use .
use ../my-hugo-module
Use the `use` directive to list module paths, including the main project (`.`). Start the Hugo server with the workspace enabled:
HUGO_MODULE_WORKSPACE=hugo.work hugo server --ignoreVendorPaths "**"
The `--ignoreVendorPaths` flag, used to ignore vendored dependencies (if applicable), enables live reloading of local edits within the workspace.
Graph
-----
To generate a [dependency graph](https://gohugo.io/quick-reference/glossary/#dependency-graph)
, including vendoring, module replacement, and disabled module information, execute `hugo mod graph` within the target module directory. For example:
$ hugo mod graph
github.com/bep/my-modular-site github.com/bep/hugotestmods/mymounts@v1.2.0
github.com/bep/my-modular-site github.com/bep/hugotestmods/mypartials@v1.0.7
github.com/bep/hugotestmods/mypartials@v1.0.7 github.com/bep/hugotestmods/myassets@v1.0.4
github.com/bep/hugotestmods/mypartials@v1.0.7 github.com/bep/hugotestmods/myv2@v1.0.0
DISABLED github.com/bep/my-modular-site github.com/spf13/hyde@v0.0.0-20190427180251-e36f5799b396
github.com/bep/my-modular-site github.com/bep/hugo-fresh@v1.0.1
github.com/bep/my-modular-site in-themesdir
Mounts
------
Imported modules automatically mount their component directories to Hugo’s [unified file system](https://gohugo.io/quick-reference/glossary/#unified-file-system)
. You can also manually mount any directory, including those from non-Hugo projects, to component directories.
See [configuring module mounts](https://gohugo.io/configuration/module/#mounts)
for details.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/hugo-modules/use-modules.md)
---
# Search tools
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

See some of the open-source and commercial search options for your newly created Hugo website.
A static website with a dynamic search function? Yes, Hugo provides an alternative to embeddable scripts from Google or other search engines for static websites. Hugo allows you to provide your visitors with a custom search function by indexing your content files directly.
Open-source
-----------
[Pagefind](https://github.com/cloudcannon/pagefind)
A fully static search library that aims to perform well on large sites, while using as little of your users’ bandwidth as possible.
[GitHub Gist for Hugo Workflow](https://gist.github.com/sebz/efddfc8fdcb6b480f567)
This gist contains a simple workflow to create a search index for your static website. It uses a simple Grunt script to index all your content files and [lunr.js](https://lunrjs.com/)
to serve the search results.
[hugo-lunr](https://www.npmjs.com/package/hugo-lunr)
A simple way to add site search to your static Hugo site using [lunr.js](https://lunrjs.com/)
. Hugo-lunr will create an index file of any HTML and Markdown documents in your Hugo project.
[hugo-lunr-zh](https://www.npmjs.com/package/hugo-lunr-zh)
A bit like Hugo-lunr, but Hugo-lunr-zh can help you separate the Chinese keywords.
[GitHub Gist for Fuse.js integration](https://gist.github.com/eddiewebb/735feb48f50f0ddd65ae5606a1cb41ae)
This gist demonstrates how to leverage Hugo’s existing build time processing to generate a searchable JSON index used by [Fuse.js](https://fusejs.io/)
on the client side. Although this gist uses Fuse.js for fuzzy matching, any client-side search tool capable of reading JSON indexes will work. Does not require npm, grunt, or other build-time tools except Hugo!
[hugo-search-index](https://www.npmjs.com/package/hugo-search-index)
A library containing Gulp tasks and a prebuilt browser script that implements search. Gulp generates a search index from project Markdown files.
[hugofastsearch](https://gist.github.com/cmod/5410eae147e4318164258742dd053993)
A usability and speed update to “GitHub Gist for Fuse.js integration” — global, keyboard-optimized search.
[JS & Fuse.js tutorial](https://makewithhugo.com/add-search-to-a-hugo-site/)
A simple client-side search solution, using FuseJS (does not require jQuery).
[Hugo Lyra](https://github.com/paolomainardi/hugo-lyra)
Hugo-Lyra is a JavaScript module to integrate [Lyra](https://github.com/LyraSearch/lyra)
into a Hugo website. It contains the server-side part to generate the index and the client-side library (optional) to bootstrap the search engine easily.
[INFINI Pizza for WebAssembly](https://github.com/infinilabs/pizza-docsearch)
Pizza is a super-lightweight yet fully featured search engine written in Rust. You can quickly add offline search functionality to your Hugo website in just five minutes with only three lines of code. For a step-by-step guide on integrating it with Hugo, check out [this blog tutorial](https://dev.to/medcl/adding-search-functionality-to-a-hugo-static-site-based-on-infini-pizza-for-webassembly-4h5e)
.
Commercial
----------
[Algolia DocSearch](https://docsearch.algolia.com/)
Algolia DocSearch is free for public technical documentation sites and easy to set up. For other use cases, [Algolia’s Search API](https://www.algolia.com/)
makes it easy to deliver a great search experience in your apps and websites. Algolia Search provides hosted full-text, numerical, faceted, and geolocalized search.
[Bonsai](https://www.bonsai.io/)
Bonsai is a fully-managed hosted Elasticsearch service that is fast, reliable, and simple to set up. Easily ingest your docs from Hugo into Elasticsearch following [this guide from the docs](https://bonsai.io/docs/hugo)
.
[ExpertRec](https://www.expertrec.com/)
ExpertRec is a hosted search-as-a-service solution that is fast and scalable. Set-up and integration is extremely easy and takes only a few minutes. The search settings can be modified without coding using a dashboard.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/tools/search.md)
---
# Theme components
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hugo provides advanced theming support with theme components.
A project can configure a theme as a composite of as many theme components as you need:
theme:
- my-shortcodes
- base-theme
- hyde
theme = ['my-shortcodes', 'base-theme', 'hyde']
{
"theme": [\
"my-shortcodes",\
"base-theme",\
"hyde"\
]
}
You can even nest this, and have the theme component itself include theme components in its own `hugo.toml` (theme inheritance).
The theme definition example above in `hugo.toml` creates a theme with 3 theme components with precedence from left to right.
For any given file, data entry, etc., Hugo will look first in the project and then in `my-shortcodes`, `base-theme`, and lastly `hyde`.
Hugo uses two different algorithms to merge the file systems, depending on the file type:
* For `i18n` and `data` files, Hugo merges deeply using the translation ID and data key inside the files.
* For `static`, `layouts` (templates), and `archetypes` files, these are merged on file level. So the left-most file will be chosen.
The name used in the `theme` definition above must match a directory in `/your-site/themes`, e.g. `/your-site/themes/my-shortcodes`.
Also note that a component that is part of a theme can have its own configuration file, e.g. `hugo.toml`. There are currently some restrictions to what a theme component can configure:
* `params` (global and per language)
* `menu` (global and per language)
* `outputformats` and `mediatypes`
The same rules apply here: The left-most parameter/menu etc. with the same ID will win. There are some hidden and experimental namespace support in the above, which we will work to improve in the future, but theme authors are encouraged to create their own namespaces to avoid naming conflicts.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/hugo-modules/theme-components.md)
---
# Templates
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### New template system\
\
Overview of the new template system in Hugo v0.146.0.](https://gohugo.io/templates/new-templatesystem-overview/)
[### Introduction\
\
An introduction to Hugo's templating syntax.](https://gohugo.io/templates/introduction/)
[### Lookup order\
\
Hugo uses the rules below to select a template for a given page, starting from the most specific.](https://gohugo.io/templates/lookup-order/)
[### Template types\
\
Create templates of different types to render your content, resources, and data.](https://gohugo.io/templates/types/)
[### Shortcode templates\
\
Create custom shortcodes to simplify and standardize content creation.](https://gohugo.io/templates/shortcode/)
[### Sitemap templates\
\
Hugo provides built-in sitemap templates.](https://gohugo.io/templates/sitemap/)
[### RSS templates\
\
Use the embedded RSS template, or create your own.](https://gohugo.io/templates/rss/)
[### Menu templates\
\
Create templates to render one or more menus.](https://gohugo.io/templates/menu/)
[### Pagination\
\
Split a list page into two or more subsets.](https://gohugo.io/templates/pagination/)
[### Partial decorators\
\
Use partial decorators to create reusable wrapper components that enclose and compose template content.](https://gohugo.io/templates/partial-decorators/)
[### Embedded partial templates\
\
Hugo provides embedded partial templates for common use cases.](https://gohugo.io/templates/embedded/)
[### robots.txt templates\
\
Hugo can generate a customized robots.txt in the same way as any other template.](https://gohugo.io/templates/robots/)
[### 404 templates\
\
Create a template to render a 404 error page.](https://gohugo.io/templates/404/)
---
# Basic usage
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Use the command-line interface (CLI) to perform basic tasks.
Test your installation
----------------------
After [installing](https://gohugo.io/installation/)
Hugo, test your installation by running:
hugo version
You should see something like:
hugo v0.155.3-8a858213b73907e823e2be2b5640a0ce4c04d295+extended linux/amd64 BuildDate=2026-02-08T16:40:42Z VendorInfo=gohugoio
Display available commands
--------------------------
To see a list of the available commands and flags:
hugo help
To get help with a subcommand, use the `--help` flag. For example:
hugo server --help
Build your project
------------------
To build your project, `cd` into your project directory and run:
hugo build
The [`hugo build`](https://gohugo.io/commands/hugo/)
command builds your project, publishing the files to the `public` directory. To publish your project to a different directory, use the [`--destination`](https://gohugo.io/commands/hugo/#options)
flag or set [`publishDir`](https://gohugo.io/configuration/all/#publishdir)
in your project configuration.
Hugo does not clear the `public` directory before building your project. Existing files are overwritten, but not deleted. This behavior is intentional to prevent the inadvertent removal of files that you may have added to the `public` directory after the build.
Depending on your needs, you may wish to manually clear the contents of the `public` directory before every build.
Draft, future, and expired content
----------------------------------
Hugo allows you to set `draft`, `date`, `publishDate`, and `expiryDate` in the [front matter](https://gohugo.io/content-management/front-matter/)
of your content. By default, Hugo will not publish content when:
* The `draft` value is `true`
* The `date` is in the future
* The `publishDate` is in the future
* The `expiryDate` is in the past
Hugo publishes descendants of draft, future, and expired [node](https://gohugo.io/quick-reference/glossary/#node)
pages. To prevent publication of these descendants, use the [`cascade`](https://gohugo.io/content-management/front-matter/#cascade)
front matter field to cascade [build options](https://gohugo.io/content-management/build-options/)
to the descendant pages.
You can override the default behavior when running `hugo build` or `hugo server` with command line flags:
hugo build --buildDrafts # or -D
hugo build --buildExpired # or -E
hugo build --buildFuture # or -F
Although you can also set these values in your project configuration, it can lead to unwanted results unless all content authors are aware of, and understand, the settings.
As noted above, Hugo does not clear the `public` directory before building your project. Depending on the _current_ evaluation of the four conditions above, after the build your `public` directory may contain extraneous files from a previous build.
A common practice is to manually clear the contents of the `public` directory before each build to remove draft, expired, and future content.
Develop and test your site
--------------------------
To view your site while developing layouts or creating content, `cd` into your project directory and run:
hugo server
The [`hugo server`](https://gohugo.io/commands/hugo_server/)
command builds your site and serves your pages using a minimal HTTP server. When you run `hugo server` it will display the URL of your local site:
Web Server is available at http://localhost:1313/
While the server is running, it watches your project directory for changes to assets, configuration, content, data, layouts, translations, and static files. When it detects a change, the server rebuilds your site and refreshes your browser using [LiveReload](https://github.com/livereload/livereload-js)
.
Most Hugo builds are so fast that you may not notice the change unless you are looking directly at your browser.
### LiveReload
While the server is running, Hugo injects JavaScript into the generated HTML pages. The LiveReload script creates a connection from the browser to the server via web sockets. You do not need to install any software or browser plugins, nor is any configuration required.
### Automatic redirection
When editing content, if you want your browser to automatically redirect to the page you last modified, run:
hugo server --navigateToChanged
Deploy your site
----------------
As noted above, Hugo does not clear the `public` directory before building your project. Manually clear the contents of the `public` directory before each build to remove draft, expired, and future content.
When you are ready to deploy your site, run:
hugo
This builds your site, publishing the files to the `public` directory. The directory structure will look something like this:
public/
├── categories/
│ ├── index.html
│ └── index.xml <-- RSS feed for this section
├── posts/
│ ├── my-first-post/
│ │ └── index.html
│ ├── index.html
│ └── index.xml <-- RSS feed for this section
├── tags/
│ ├── index.html
│ └── index.xml <-- RSS feed for this section
├── index.html
├── index.xml <-- RSS feed for the site
└── sitemap.xml
In a simple hosting environment, where you typically `ftp`, `rsync`, or `scp` your files to the root of a virtual host, the contents of the `public` directory are all that you need.
Most of our users deploy their sites to a [CI/CD](https://gohugo.io/quick-reference/glossary/#cicd)
platform, where a push[1](https://gohugo.io/getting-started/usage/#fn:1)
to their remote Git repository triggers a build and deployment. Learn more in the [host and deploy](https://gohugo.io/host-and-deploy/)
section.
* * *
1. The Git repository contains the entire project directory, typically excluding the `public` directory because the site is built _after_ the push. [↩︎](https://gohugo.io/getting-started/usage/#fnref:1)
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/getting-started/usage.md)
---
# License
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hugo is released under the Apache 2.0 license.
Apache License
--------------
_Version 2.0, January 2004_
_[http://www.apache.org/licenses/](http://www.apache.org/licenses/)
_
### Terms and Conditions for use, reproduction, and distribution
#### 1\. Definitions
“License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
“Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
“Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means **(i)** the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the outstanding shares, or **(iii)** beneficial ownership of such entity.
“You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License.
“Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
“Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
“Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
“Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
“Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.”
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
#### 2\. Grant of Copyright License
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
#### 3\. Grant of Patent License
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
#### 4\. Redistribution
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
* **(a)** You must give any other recipients of the Work or Derivative Works a copy of this License; and
* **(b)** You must cause any modified files to carry prominent notices stating that You changed the files; and
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
#### 5\. Submission of Contributions
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
#### 6\. Trademarks
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
#### 7\. Disclaimer of Warranty
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
#### 8\. Limitation of Liability
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
#### 9\. Accepting Warranty or Additional Liability
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/about/license.md)
---
# External learning resources
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Use these third-party resources to learn Hugo.
Many of the resources on this page, including older books and videos, may contain out-of-date information. The Hugo software has undergone significant changes since these resources were created. These changes include the introduction of a new template system, the deprecation of various functions and settings, and the addition of new features like Markdown render hooks, content adapters, and support for mathematical markup. While some concepts may still be relevant, it’s recommended to consult the official Hugo documentation for the most current and accurate information.
Books
-----
### Hugo in Action
Hugo in Action is a step-by-step guide to using Hugo to create static websites. Working with a complete example website and source code samples, you’ll learn how to build and host a low-maintenance, high-performance site that will wow your users and stay stable without relying on a third-party server.
[](https://www.manning.com/books/hugo-in-action/)
Author: Atishay Jain
Publisher: [Manning Publications](https://www.manning.com/books/hugo-in-action/)
Publication date: March 2022
Length: 488 pages
ISBN: 9781617297007
### Build Websites with Hugo
In this book, you’ll use Hugo to build a personal portfolio site that you can use to showcase your skills and thoughts to the world. You’ll build the basic skeleton, develop a custom theme, and use content templates to generate new pages quickly. You’ll use internal and external data sources to embed content into your site and render some of your content in JSON and RSS. You’ll add a blog section with posts and integrate Disqus with your site, and then make your site searchable.
[](https://pragprog.com/titles/bhhugo/build-websites-with-hugo/)
Author: Brian P. Hogan
Publisher: [Pragmatic Bookshelf](https://pragprog.com/titles/bhhugo/build-websites-with-hugo/)
Publication date: May 2020
Length: 154 pages
ISBN: 9781680507263
Videos
------
### Hugo Beginner Tutorial Series
Welcome to this introduction to Hugo tutorial. This series aims to take you from a lion cub with basic web design knowledge to creating your first Hugo website. In this series, you’ll learn how to set up a Hugo site, the basics of using Hugo layouts, partials, and templating, set up a blog, and finally, use data files. By the end of this series, you’ll have the foundational knowledge to build your own Hugo sites.
1. [Getting set up in Hugo](https://cloudcannon.com/tutorials/hugo-beginner-tutorial/)
2. [Layouts in Hugo](https://cloudcannon.com/tutorials/hugo-beginner-tutorial/layouts-in-hugo/)
3. [Hugo Partials](https://cloudcannon.com/tutorials/hugo-beginner-tutorial/hugo-partials/)
4. [Hugo templating basics](https://cloudcannon.com/tutorials/hugo-beginner-tutorial/hugo-templating-basics/)
5. [Blogging in Hugo](https://cloudcannon.com/tutorials/hugo-beginner-tutorial/blogging-in-hugo/)
6. [Using Data in Hugo](https://cloudcannon.com/tutorials/hugo-beginner-tutorial/using-data-in-hugo/)
Creator: Mike Neumegen
Affiliation: [CloudCannon](https://cloudcannon.com/)
Creation date: April 2022
### Hugo Static Site Generator
This course covers the basics of using the Hugo static site generator. Work your way through the articles, and we’ll teach you everything you need to know to create a professional and scalable website or blog!
1. [Introduction](https://www.giraffeacademy.com/static-site-generators/hugo/)
2. [Windows Installation](https://www.giraffeacademy.com/static-site-generators/hugo/installing-hugo-on-windows/)
3. [Mac Installation](https://www.giraffeacademy.com/static-site-generators/hugo/installing-hugo-on-mac/)
4. [Creating A New Site](https://www.giraffeacademy.com/static-site-generators/hugo/hugo-directory-structure/)
5. [Installing & Using Themes](https://www.giraffeacademy.com/static-site-generators/hugo/installing-using-themes/)
6. [Content Organization](https://www.giraffeacademy.com/static-site-generators/hugo/content-organization/)
7. [Front Matter](https://www.giraffeacademy.com/static-site-generators/hugo/front-matter/)
8. [Archetypes](https://www.giraffeacademy.com/static-site-generators/hugo/archetypes/)
9. [Shortcodes](https://www.giraffeacademy.com/static-site-generators/hugo/shortcodes/)
10. [Taxonomies](https://www.giraffeacademy.com/static-site-generators/hugo/taxonomies/)
11. [Template Basics](https://www.giraffeacademy.com/static-site-generators/hugo/introduction-to-templates/)
12. [List Page Templates](https://www.giraffeacademy.com/static-site-generators/hugo/list-page-templates/)
13. [Single Page Templates](https://www.giraffeacademy.com/static-site-generators/hugo/single-page-templates/)
14. [Home Page Templates](https://www.giraffeacademy.com/static-site-generators/hugo/home-page-templates/)
15. [Section Templates](https://www.giraffeacademy.com/static-site-generators/hugo/section-templates/)
16. [Block Templates](https://www.giraffeacademy.com/static-site-generators/hugo/block-templates/)
17. [Variables](https://www.giraffeacademy.com/static-site-generators/hugo/variables/)
18. [Functions](https://www.giraffeacademy.com/static-site-generators/hugo/functions/)
19. [Conditionals](https://www.giraffeacademy.com/static-site-generators/hugo/conditionals/)
20. [Data Templates](https://www.giraffeacademy.com/static-site-generators/hugo/data-templates/)
21. [Partial Templates](https://www.giraffeacademy.com/static-site-generators/hugo/partial-templates/)
22. [Shortcode Templates](https://www.giraffeacademy.com/static-site-generators/hugo/shortcode-templates/)
23. [Building & Hosting](https://www.giraffeacademy.com/static-site-generators/hugo/building-&-hosting/)
Creator: Mike Dane
Affiliation: [Giraffe Academy](https://www.giraffeacademy.com/)
Creation date: September 2017
* * *
Last updated: August 23, 2025 : [Merge commit 'bfa74537929f409fca841540b971125b7678963a' (6c911d1e5)](https://github.com/gohugoio/hugoDocs/commit/6c911d1e52fb9c8065c079820327f4b0e37529d4)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/getting-started/external-learning-resources/index.md)
---
# Security model
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

A summary of Hugo’s security model.
Runtime security
----------------
Hugo generates static websites, meaning the final output runs directly in the browser and interacts with any integrated APIs. However, during development and site building, the `hugo` executable itself is the runtime environment.
Securing a runtime is a complex task. Hugo addresses this through a robust sandboxing approach and a strict security policy with default protections. Key features include:
* Virtual file system: Hugo employs a virtual file system, limiting file access. Only the main project, not external components, can access files or directories outside the project root.
* Read-Only access: User-defined components have read-only access to the file system, preventing unintended modifications.
* Controlled external binaries: While Hugo utilizes external binaries for features like Asciidoctor support, these are strictly predefined with specific flags and are disabled by default. The [security policy](https://gohugo.io/configuration/security/)
details these limitations.
* No arbitrary commands: To mitigate risks, Hugo intentionally avoids implementing general functions that would allow users to execute arbitrary operating system commands.
This combination of sandboxing and strict defaults effectively minimizes potential security vulnerabilities during the Hugo build process.
Dependency security
-------------------
Hugo utilizes [Go Modules](https://go.dev/wiki/Modules#modules)
to manage its dependencies, compiling as a static binary. Go Modules create a `go.sum` file, a critical security feature. This file acts as a database, storing the expected cryptographic checksums of all dependencies, including those required indirectly (transitive dependencies).
[Hugo Modules](https://gohugo.io/hugo-modules/)
, which extend Go Modules’ functionality, also produce a `go.sum` file. To ensure dependency integrity, commit this `go.sum` file to your version control. If Hugo detects a checksum mismatch during the build process, it will fail, indicating a possible attempt to [tamper with your project’s dependencies](https://julienrenaux.fr/2019/12/20/github-actions-security-risk/)
.
Web application security
------------------------
Hugo’s security philosophy is rooted in established security standards, primarily aligning with the threats defined by [OWASP](https://en.wikipedia.org/wiki/OWASP)
. For HTML output, Hugo operates under a clear trust model. This model assumes that template and configuration authors, the developers, are trustworthy. However, the data supplied to these templates is inherently considered untrusted. This distinction is crucial for understanding how Hugo handles potential security risks.
To prevent unintended escaping of data that developers know is safe, Hugo provides [`safe`](https://gohugo.io/functions/safe/)
functions, such as [`safeHTML`](https://gohugo.io/functions/safe/html/)
. These functions allow developers to explicitly mark data as trusted, bypassing the default escaping mechanisms. This is essential for scenarios where data is generated or sourced from reliable sources. However, an exception exists: enabling [inline shortcodes](https://gohugo.io/content-management/shortcodes/#inline)
. By activating this feature, you are implicitly trusting the logic within the shortcodes and the data contained within your content files.
It’s vital to remember that Hugo is a static site generator. This architectural choice significantly reduces the attack surface by eliminating the complexities and vulnerabilities associated with dynamic user input. Unlike dynamic websites, Hugo generates static HTML files, minimizing the risk of real-time attacks. Regarding content, Hugo’s default Markdown renderer is [configured to sanitize](https://gohugo.io/configuration/markup/#rendererunsafe)
potentially unsafe content. This default behavior ensures that potentially malicious code or scripts are removed or escaped. However, this setting can be reconfigured if you have a high degree of confidence in the safety of your content sources.
In essence, Hugo prioritizes secure output by establishing a clear trust boundary between developers and data. By default, it errs on the side of caution, sanitizing potentially unsafe content and escaping data. Developers have the flexibility to adjust these defaults through [`safe`](https://gohugo.io/functions/safe/)
functions and [configuration options](https://gohugo.io/configuration/security/)
, but they must do so with a clear understanding of the security implications. Hugo’s static site generation model further strengthens its security posture by minimizing dynamic vulnerabilities.
Configuration
-------------
See [configure security](https://gohugo.io/configuration/security/)
.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/about/security.md)
---
# Other community projects
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Some interesting projects developed by the Hugo community that don’t quite fit into our other developer tool categories.
And for all the other community projects around Hugo:
* [diego](https://github.com/ttybitnik/diego)
- A CLI tool that integrates with Hugo to assist in importing and utilizing exported social media data from popular services on Hugo websites.
* [Emacs Easy Hugo](https://github.com/masasam/emacs-easy-hugo)
- Emacs package for writing blog posts in Markdown or org-mode and building your project with Hugo.
* [Hugo SFTP Upload](https://github.com/thomasmey/HugoSftpUpload)
- Sync the local build of your Hugo website with your remote web server via SFTP.
* [HugoPhotoSwipe](https://github.com/GjjvdBurg/HugoPhotoSwipe)
- Make it easy to create image galleries using PhotoSwipe.
* [JAMStack Themes](https://jamstackthemes.dev/ssg/hugo/)
- A collection of site themes filterable by static site generator and supported CMS to help build CMS-connected sites using Hugo (linking to Hugo-specific themes).
* [flickr-hugo-embed](https://github.com/nikhilm/flickr-hugo-embed)
- Print shortcodes to embed a set of images from an album on Flickr into Hugo.
* [hugo-gallery](https://github.com/icecreammatt/hugo-gallery)
- Create an image gallery for Hugo sites.
* [hugo-openapispec-shortcode](https://github.com/tenfourty/hugo-openapispec-shortcode)
- A shortcode that allows you to include [Open API Spec](https://openapis.org/)
(formerly known as Swagger Spec) in a page.
* [plausible-hugo](https://github.com/divinerites/plausible-hugo)
- Easy Hugo integration for Plausible Analytics, a simple, open-source, lightweight and privacy-friendly web analytics alternative to Google Analytics.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/tools/other.md)
---
# Directory structure
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

An overview of Hugo’s directory structure.
Each Hugo project is a directory, with subdirectories that contribute to content, structure, behavior, and presentation.
Project skeleton
----------------
Hugo generates a project skeleton when you create a new project. For example, this command:
hugo new project my-project
Creates this directory structure:
my-project/
├── archetypes/
│ └── default.md
├── assets/
├── content/
├── data/
├── i18n/
├── layouts/
├── static/
├── themes/
└── hugo.toml <-- project configuration
Depending on requirements, you may wish to organize your project configuration into subdirectories:
my-project/
├── archetypes/
│ └── default.md
├── assets/
├── config/ <-- project configuration
│ └── _default/
│ └── hugo.toml
├── content/
├── data/
├── i18n/
├── layouts/
├── static/
└── themes/
When you build your project, Hugo creates a `public` directory, and typically a `resources` directory as well:
my-project/
├── archetypes/
│ └── default.md
├── assets/
├── config/
│ └── _default/
│ └── hugo.toml
├── content/
├── data/
├── i18n/
├── layouts/
├── public/ <-- created when you build your project
├── resources/ <-- created when you build your project
├── static/
└── themes/
Directories
-----------
Each of the subdirectories contributes to content, structure, behavior, or presentation.
archetypes
The `archetypes` directory contains templates for new content. See [details](https://gohugo.io/content-management/archetypes/)
.
assets
The `assets` directory contains global resources typically passed through an asset pipeline. This includes resources such as images, CSS, Sass, JavaScript, and TypeScript. See [details](https://gohugo.io/hugo-pipes/introduction/)
.
config
The `config` directory contains your project configuration, possibly split into multiple subdirectories and files. For projects with minimal configuration or projects that do not need to behave differently in different environments, a single configuration file named `hugo.toml` in the root of the project is sufficient. See [details](https://gohugo.io/configuration/introduction/#configuration-directory)
.
content
The `content` directory contains the markup files (typically Markdown) and page resources that comprise the content of your project. See [details](https://gohugo.io/content-management/organization/)
.
data
The `data` directory contains data files (JSON, TOML, YAML, or XML) that augment content, configuration, localization, and navigation. See [details](https://gohugo.io/content-management/data-sources/)
.
i18n
The `i18n` directory contains translation tables for multilingual projects. See [details](https://gohugo.io/content-management/multilingual/)
.
layouts
The `layouts` directory contains templates to transform content, data, and resources into a complete website. See [details](https://gohugo.io/templates/)
.
public
The `public` directory contains the published website, generated when you run the `hugo build` or `hugo server` commands. Hugo recreates this directory and its content as needed. See [details](https://gohugo.io/getting-started/usage/#build-your-project)
.
resources
The `resources` directory contains cached output from Hugo’s asset pipelines, generated when you run the `hugo build` or `hugo server` commands. By default this cache directory includes CSS and images. Hugo recreates this directory and its content as needed.
static
The `static` directory contains files that will be copied to the `public` directory when you build your project. For example: `favicon.ico`, `robots.txt`, and files that verify website ownership. Before the introduction of [page bundles](https://gohugo.io/quick-reference/glossary/#page-bundle)
and [asset pipelines](https://gohugo.io/hugo-pipes/introduction/)
, the `static` directory was also used for images, CSS, and JavaScript.
themes
The `themes` directory contains one or more [themes](https://gohugo.io/quick-reference/glossary/#theme)
, each in its own subdirectory.
Union file system
-----------------
Hugo creates a union file system, allowing you to mount two or more directories to the same location. For example, let’s say your home directory contains a Hugo project in one directory, and shared content in another:
home/
└── user/
├── my-project/
│ ├── content/
│ │ ├── books/
│ │ │ ├── _index.md
│ │ │ ├── book-1.md
│ │ │ └── book-2.md
│ │ └── _index.md
│ ├── themes/
│ │ └── my-theme/
│ └── hugo.toml
└── shared-content/
└── films/
├── _index.md
├── film-1.md
└── film-2.md
You can include the shared content using mounts. In your project configuration:
module:
mounts:
- source: content
target: content
- source: /home/user/shared-content
target: content
[module]
[[module.mounts]]
source = 'content'
target = 'content'
[[module.mounts]]
source = '/home/user/shared-content'
target = 'content'
{
"module": {
"mounts": [\
{\
"source": "content",\
"target": "content"\
},\
{\
"source": "/home/user/shared-content",\
"target": "content"\
}\
]
}
}
When you overlay one directory on top of another, you must mount both directories.
Hugo does not follow symbolic links. If you need the functionality provided by symbolic links, use Hugo’s union file system instead.
After mounting, the union file system has this structure:
home/
└── user/
└── my-project/
├── content/
│ ├── books/
│ │ ├── _index.md
│ │ ├── book-1.md
│ │ └── book-2.md
│ ├── films/
│ │ ├── _index.md
│ │ ├── film-1.md
│ │ └── film-2.md
│ └── _index.md
├── themes/
│ └── my-theme/
└── hugo.toml
When two or more files have the same path, the order of precedence follows the order of the mounts. For example, if the shared content directory contains `books/book-1.md`, it will be ignored because the project’s `content` directory was mounted first.
You can mount directories to `archetypes`, `assets`, `content`, `data`, `i18n`, `layouts`, and `static`. See [details](https://gohugo.io/configuration/module/#mounts)
.
You can also mount directories from Git repositories using Hugo Modules. See [details](https://gohugo.io/hugo-modules/)
.
Theme skeleton
--------------
Hugo generates a functional theme skeleton when you create a new theme. For example, this command:
hugo new theme my-theme
Creates this directory structure (subdirectories not shown):
my-theme/
├── archetypes/
├── assets/
├── content/
├── data/
├── i18n/
├── layouts/
├── static/
└── hugo.toml
Using the union file system described above, Hugo mounts each of these directories to the corresponding location in the project. When two files have the same path, the file in the project directory takes precedence. This allows you, for example, to override a theme’s template by placing a copy in the same location within the project directory.
If you are simultaneously using components from two or more themes or modules, and there’s a path collision, the first mount takes precedence.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/getting-started/directory-structure.md)
---
# Migrate to Hugo
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

A list of community-developed tools for migrating from your existing static site generator or content management system to Hugo.
This section highlights some independently developed projects related to Hugo. These tools extend functionality or help you to get started.
Take a look at this list of migration tools if you currently use other blogging tools like Jekyll or WordPress but intend to switch to Hugo instead. They’ll help you export your content into Hugo-friendly formats.
Jekyll
------
Alternatively, you can use the [Jekyll import command](https://gohugo.io/commands/hugo_import_jekyll/)
.
[JekyllToHugo](https://github.com/fredrikloch/JekyllToHugo)
A Small script for converting Jekyll blog posts to a Hugo site.
[ConvertToHugo](https://github.com/coderzh/ConvertToHugo)
Convert your blog from Jekyll to Hugo.
Octopress
---------
[octohug](https://github.com/codebrane/octohug)
Octopress to Hugo migrator.
DokuWiki
--------
[dokuwiki-to-hugo](https://github.com/wgroeneveld/dokuwiki-to-hugo)
Migrates your DokuWiki source pages from [DokuWiki syntax](https://www.dokuwiki.org/wiki:syntax)
to Hugo Markdown syntax. Includes extras like the TODO plugin. Written with extensibility in mind using Python 3. Also generates a TOML header for each page. Designed to copy-paste the wiki directory into your `content` directory.
WordPress
---------
[wordpress-to-hugo-exporter](https://github.com/SchumacherFM/wordpress-to-hugo-exporter)
A one-click WordPress plugin that converts all posts, pages, taxonomies, metadata, and settings to Markdown and YAML which can be dropped into Hugo. (Note: If you have trouble using this plugin, you can [export your site for Jekyll](https://wordpress.org/plugins/jekyll-exporter/)
and use Hugo’s built-in Jekyll converter listed above.)
[blog2md](https://github.com/palaniraja/blog2md)
Works with [exported xml](https://en.support.wordpress.com/export/)
file of your free YOUR-TLD.wordpress.com website. It also saves approved comments to `YOUR-POST-NAME-comments.md` file along with posts.
[wordhugopress](https://github.com/nantipov/wordhugopress)
A small utility written in Java that exports the entire WordPress site from the database and resource (e.g., images) files stored locally or remotely. Therefore, migration from the backup files is possible. Supports merging multiple WordPress sites into a single Hugo site.
[wp2hugo](https://github.com/ashishb/wp2hugo)
A Go-based CLI tool to migrate WordPress websites to Hugo. It preserves original URLs, GUIDs, image URLs, code highlights, tables of contents, and WordPress navigation categories. It migrates WordPress custom post types, custom taxonomies, custom fields, and page hierarchy. It supports translated WordPress blogs via Polylang or WPML. It imports a WordPress media library database with original titles and dates. The tool can download all media or only media inserted into pages from the original server. It converts WordPress shortcodes and Gutenberg blocks to Hugo shortcodes including galleries, images, audio, YouTube embeds, Gists, and Google Maps.
Medium
------
[medium2md](https://github.com/gautamdhameja/medium-2-md)
A simple Medium to Hugo exporter able to import stories in one command, including front matter.
[medium-to-hugo](https://github.com/bgadrian/medium-to-hugo)
A CLI tool written in Go to export medium posts into a Hugo-compatible Markdown format. Tags and images are included. All images will be downloaded locally and linked appropriately.
Tumblr
------
[tumblr-importr](https://github.com/carlmjohnson/tumblr-importr)
An importer that uses the Tumblr API to create a Hugo static site.
[tumblr2hugomarkdown](https://github.com/Wysie/tumblr2hugomarkdown)
Export all your Tumblr content to Hugo Markdown files with preserved original formatting.
[Tumblr to Hugo](https://github.com/jipiboily/tumblr-to-hugo)
A migration tool that converts each of your Tumblr posts to a content file with a proper title and path. It also generates a CSV file to help you set up URL redirects.
Drupal
------
[drupal2hugo](https://github.com/danapsimer/drupal2hugo)
Convert a Drupal site to Hugo.
Joomla
------
[hugojoomla](https://github.com/davetcc/hugojoomla)
This utility written in Java takes a Joomla database and converts all the content into Markdown files. It changes any URLs that are in Joomla’s internal format and converts them to a suitable form.
Blogger
-------
[blogimport](https://github.com/natefinch/blogimport)
A tool to import from Blogger posts to Hugo.
[blogger-to-hugo](https://pypi.org/project/blogger-to-hugo/)
Another tool to import Blogger posts to Hugo. It also downloads embedded images so they will be stored locally.
[blog2md](https://github.com/palaniraja/blog2md)
Works with [exported xml](https://support.google.com/blogger/answer/41387?hl=en)
file of your YOUR-TLD.blogspot.com website. It also saves comments to `YOUR-POST-NAME-comments.md` file along with posts.
[BloggerToHugo](https://github.com/huanlin/blogger-to-hugo)
Yet another tool to import Blogger posts to Hugo. For Windows platform only, and .NET Framework 4.5 is required. See README.md before using this tool.
[blogger2hugo](https://github.com/noorkhafidzin/blogger2hugo)
Converts a Blogger backup file (`.atom`) from [Google Takeout](https://takeout.google.com/takeout/custom/blogger?hl=en)
to Markdown (`.md`) files. The tool generates output compatible with the Hugo `content/` structure.
Contentful
----------
[contentful-hugo](https://github.com/ModiiMedia/contentful-hugo)
A tool to create content-files for Hugo from content on [Contentful](https://www.contentful.com/)
.
BlogML
------
[BlogML2Hugo](https://github.com/jijiechen/BlogML2Hugo)
A tool that helps you convert BlogML xml file to Hugo Markdown files. Users need to take care of links to attachments and images by themselves. This helps the blogs that export BlogML files (e.g. BlogEngine.NET) transform to hugo sites easily.
* * *
Last updated: February 26, 2026 : [content: Add blogger2hugo migration tool (291ffc3f6)](https://github.com/gohugoio/hugoDocs/commit/291ffc3f6bbfc43d218748c729a1c4b3f996ed6a)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/tools/migrations.md)
---
# Template lookup order
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hugo uses the rules below to select a template for a given page, starting from the most specific.
We did a complete overhaul of Hugo’s template system in v0.146.0. We’re working on getting all of the relevant documentation up to date, but until then, see [this page](https://gohugo.io/templates/new-templatesystem-overview/)
.
Lookup rules
------------
Hugo takes the parameters listed below into consideration when choosing a template for a given page. The templates are ordered by specificity. This should feel natural, but look at the table below for concrete examples of the different parameter variations.
Kind
The page `Kind` (the home page is one). See the example tables below per kind. This also determines if it is a **single page** (i.e. a regular content page. We then look for a template in `_default/single.html` for HTML) or a **list page** (section listings, home page, taxonomy lists, taxonomy terms. We then look for a template in `_default/list.html` for HTML).
Layout
Can be set in front matter.
Output Format
See [configure output formats](https://gohugo.io/configuration/output-formats/)
. An output format has both a `name` (e.g. `rss`, `amp`, `html`) and a `suffix` (e.g. `xml`, `html`). We prefer matches with both (e.g. `index.amp.html`), but look for less specific templates.
Note that if the output format’s Media Type has more than one suffix defined, only the first is considered.
Language
We will consider a language tag in the template name. If the site language is `fr`, `index.fr.amp.html` will win over `index.amp.html`, but `index.amp.html` will be chosen before `index.fr.html`.
Type
Is value of `type` if set in front matter, else it is the name of the root section (e.g. “blog”). It will always have a value, so if not set, the value is “page”.
Section
Is relevant for `section`, `taxonomy` and `term` types.
Templates can live in either the project’s or the themes’ `layout` directories, and the most specific templates will be chosen. Hugo will interleave the lookups listed below, finding the most specific one either in the project or themes.
Target a template
-----------------
You cannot change the lookup order to target a content page, but you can change a content page to target a template. Specify `type`, `layout`, or both in front matter.
Consider this content structure:
content/
├── about.md
└── contact.md
Files in the root of the `content` directory have a [content type](https://gohugo.io/quick-reference/glossary/#content-type)
of `page`. To render these pages with a unique template, create a matching subdirectory:
layouts/
└── page/
└── single.html
But the contact page probably has a form and requires a different template. In the front matter specify `layout`:
---
layout: contact
title: Contact
---
+++
layout = 'contact'
title = 'Contact'
+++
{
"layout": "contact",
"title": "Contact"
}
Then create the template for the contact page:
layouts/
└── page/
└── contact.html <-- renders contact.md
└── single.html <-- renders about.md
As a content type, the word `page` is vague. Perhaps `miscellaneous` would be better. Add `type` to the front matter of each page:
---
title: About
type: miscellaneous
---
+++
title = 'About'
type = 'miscellaneous'
+++
{
"title": "About",
"type": "miscellaneous"
}
---
layout: contact
title: Contact
type: miscellaneous
---
+++
layout = 'contact'
title = 'Contact'
type = 'miscellaneous'
+++
{
"layout": "contact",
"title": "Contact",
"type": "miscellaneous"
}
Now place the layouts in the corresponding directory:
layouts/
└── miscellaneous/
└── contact.html <-- renders contact.md
└── single.html <-- renders about.md
* * *
Last updated: July 7, 2025 : [Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45' (079671b41)](https://github.com/gohugoio/hugoDocs/commit/079671b41b9395f2c2b48879f14d3f09d69a63dc)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/lookup-order.md)
---
# Linux
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Install Hugo on Linux.
Editions
--------
Hugo offers a standard edition with core features, plus extended and extended/deploy editions with more. Use the standard edition unless you need the features below.
| Feature | extended edition | extended/deploy edition |
| --- | --- | --- |
| [Transpile Sass to CSS](https://gohugo.io/functions/css/sass/) via embedded LibSass. Note that embedded LibSass was deprecated in v0.153.0 and will be removed in a future release. Use the [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass) transpiler instead, which is compatible with any edition. | ✔️ | ✔️ |
| Deploy your site directly to a Google Cloud Storage bucket, an AWS S3 bucket, or an Azure Storage container. See [details](https://gohugo.io/host-and-deploy/deploy-with-hugo-deploy/) . | ❌ | ✔️ |
Prerequisites
-------------
Although not required in all cases, [Git](https://git-scm.com/)
, [Go](https://go.dev/)
, and [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass)
are commonly used when working with Hugo.
Git is required to:
* Build Hugo from source
* Use the [Hugo Modules](https://gohugo.io/hugo-modules/)
feature
* Install a theme as a Git submodule
* Access [commit information](https://gohugo.io/methods/page/gitinfo/)
from a local Git repository
* Host your site on [CI/CD](https://gohugo.io/quick-reference/glossary/#cicd)
platforms such as [Cloudflare](https://gohugo.io/host-and-deploy/host-on-cloudflare/)
, [GitHub Pages](https://gohugo.io/host-and-deploy/host-on-github-pages/)
, [GitLab Pages](https://gohugo.io/host-and-deploy/host-on-gitlab-pages/)
, [Netlify](https://gohugo.io/host-and-deploy/host-on-netlify/)
, [Render](https://gohugo.io/host-and-deploy/host-on-render/)
, or [Vercel](https://gohugo.io/host-and-deploy/host-on-vercel/)
Go is required to:
* Build Hugo from source
* Use the Hugo Modules feature
Dart Sass is required to transpile Sass to CSS when using the latest features of the Sass language.
Please refer to the relevant documentation for installation instructions:
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [Go](https://go.dev/doc/install)
* [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass)
Prebuilt binaries
-----------------
Prebuilt binaries are available for a variety of operating systems and architectures. Visit the [latest release](https://github.com/gohugoio/hugo/releases/latest)
page, and scroll down to the Assets section.
1. Download the archive for the desired edition, operating system, and architecture
2. Extract the archive
3. Move the executable to the desired directory
4. Add this directory to the PATH environment variable
5. Verify that you have _execute_ permission on the file
Please consult your operating system documentation if you need help setting file permissions or modifying your PATH environment variable.
If you do not see a prebuilt binary for the desired edition, operating system, and architecture, install Hugo using one of the methods described below.
Package managers
----------------
### Snap
[Snap](https://snapcraft.io/)
is a free and open-source package manager for Linux. Available for [most distributions](https://snapcraft.io/docs/installing-snapd)
, snap packages are simple to install and are automatically updated.
The Hugo snap package is [strictly confined](https://snapcraft.io/docs/snap-confinement)
. Strictly confined snaps run in complete isolation, up to a minimal access level that’s deemed always safe. The sites you create and build must be located within your home directory, or on removable media.
To install the extended edition of Hugo:
sudo snap install hugo
To control automatic updates:
# disable automatic updates
sudo snap refresh --hold hugo
# enable automatic updates
sudo snap refresh --unhold hugo
To control access to removable media:
# allow access
sudo snap connect hugo:removable-media
# revoke access
sudo snap disconnect hugo:removable-media
To control access to SSH keys:
# allow access
sudo snap connect hugo:ssh-keys
# revoke access
sudo snap disconnect hugo:ssh-keys
### Homebrew
[Homebrew](https://brew.sh/)
is a free and open-source package manager for macOS and Linux. To install the extended/deploy edition of Hugo:
brew install hugo
Repository packages
-------------------
Most Linux distributions maintain a repository for commonly installed applications.
The Hugo version available in package repositories varies based on Linux distribution and release, and in some cases will not be the [latest version](https://github.com/gohugoio/hugo/releases/latest)
.
Use one of the other installation methods if your package repository does not provide the desired version.
### Alpine Linux
To install the extended edition of Hugo on [Alpine Linux](https://alpinelinux.org/)
:
doas apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community hugo
### Arch Linux
Derivatives of the [Arch Linux](https://archlinux.org/)
distribution of Linux include [EndeavourOS](https://endeavouros.com/)
, [Garuda Linux](https://garudalinux.org/)
, [Manjaro](https://manjaro.org/)
, and others. To install the extended edition of Hugo:
sudo pacman -S hugo
### Debian
Derivatives of the [Debian](https://www.debian.org/)
distribution of Linux include [elementary OS](https://elementary.io/)
, [KDE neon](https://neon.kde.org/)
, [Linux Lite](https://www.linuxliteos.com/)
, [Linux Mint](https://linuxmint.com/)
, [MX Linux](https://mxlinux.org/)
, [Pop!\_OS](https://pop.system76.com/)
, [Ubuntu](https://ubuntu.com/)
, [Zorin OS](https://zorin.com/os/)
, and others. To install the extended edition of Hugo:
sudo apt install hugo
You can also download Debian packages from the [latest release](https://github.com/gohugoio/hugo/releases/latest)
page.
### Exherbo
To install the extended edition of Hugo on [Exherbo](https://www.exherbolinux.org/)
:
1. Add this line to /etc/paludis/options.conf:
www-apps/hugo extended
2. Install using the Paludis package manager:
cave resolve -x repository/heirecka
cave resolve -x hugo
### Fedora
Derivatives of the [Fedora](https://getfedora.org/)
distribution of Linux include [CentOS](https://www.centos.org/)
, [Red Hat Enterprise Linux](https://www.redhat.com/)
, and others. To install the extended edition of Hugo:
sudo dnf install hugo
### Gentoo
Derivatives of the [Gentoo](https://www.gentoo.org/)
distribution of Linux include [Calculate Linux](https://www.calculate-linux.org/)
, [Funtoo](https://www.funtoo.org/)
, and others. To install the extended edition of Hugo:
1. Specify the `extended` [USE](https://packages.gentoo.org/packages/www-apps/hugo)
flag in /etc/portage/package.use/hugo:
www-apps/hugo extended
2. Build using the Portage package manager:
sudo emerge www-apps/hugo
### NixOS
The NixOS distribution of Linux includes Hugo in its package repository. To install the extended edition of Hugo:
nix-env -iA nixos.hugo
### openSUSE
Derivatives of the [openSUSE](https://www.opensuse.org/)
distribution of Linux include [GeckoLinux](https://geckolinux.github.io/)
, [Linux Karmada](https://linuxkamarada.com/)
, and others. To install the extended edition of Hugo:
sudo zypper install hugo
### Solus
The [Solus](https://getsol.us/)
distribution of Linux includes Hugo in its package repository. To install the extended edition of Hugo:
sudo eopkg install hugo
### Void Linux
To install the extended edition of Hugo on [Void Linux](https://voidlinux.org/)
:
sudo xbps-install -S hugo
Build from source
-----------------
To build the extended or extended/deploy edition from source you must:
1. Install [Git](https://git-scm.com/)
2. Install [Go](https://go.dev/)
version 1.24.0 or later
3. Install a C compiler, either [GCC](https://gcc.gnu.org/)
or [Clang](https://clang.llvm.org/)
4. Update your `PATH` environment variable as described in the [Go documentation](https://go.dev/doc/code#Command)
> The install directory is controlled by the `GOPATH` and `GOBIN` environment variables. If `GOBIN` is set, binaries are installed to that directory. If `GOPATH` is set, binaries are installed to the bin subdirectory of the first directory in the `GOPATH` list. Otherwise, binaries are installed to the bin subdirectory of the default `GOPATH` (`$HOME/go` or `%USERPROFILE%\go`).
To build the standard edition:
go install github.com/gohugoio/hugo@latest
To build the extended edition:
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest
To build the extended/deploy edition:
CGO_ENABLED=1 go install -tags extended,withdeploy github.com/gohugoio/hugo@latest
Comparison
----------
| | Prebuilt binaries | Package managers | Repository packages | Build from source |
| --- | --- | --- | --- | --- |
| Easy to install? | ✔️ | ✔️ | ✔️ | ✔️ |
| Easy to upgrade? | ✔️ | ✔️ | varies | ✔️ |
| Easy to downgrade? | ✔️ | ✔️ [1](https://gohugo.io/installation/linux/#fn:1) | varies | ✔️ |
| Automatic updates? | ❌ | varies [2](https://gohugo.io/installation/linux/#fn:2) | ❌ | ❌ |
| Latest version available? | ✔️ | ✔️ | varies | ✔️ |
* * *
1. Easy if a previous version is still installed. [↩︎](https://gohugo.io/installation/linux/#fnref:1)
2. Snap packages are automatically updated. Homebrew requires advanced configuration. [↩︎](https://gohugo.io/installation/linux/#fnref:2)
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/installation/linux.md)
---
# BSD
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Install Hugo on BSD derivatives.
Editions
--------
Hugo offers a standard edition with core features, plus extended and extended/deploy editions with more. Use the standard edition unless you need the features below.
| Feature | extended edition | extended/deploy edition |
| --- | --- | --- |
| [Transpile Sass to CSS](https://gohugo.io/functions/css/sass/) via embedded LibSass. Note that embedded LibSass was deprecated in v0.153.0 and will be removed in a future release. Use the [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass) transpiler instead, which is compatible with any edition. | ✔️ | ✔️ |
| Deploy your site directly to a Google Cloud Storage bucket, an AWS S3 bucket, or an Azure Storage container. See [details](https://gohugo.io/host-and-deploy/deploy-with-hugo-deploy/) . | ❌ | ✔️ |
Prerequisites
-------------
Although not required in all cases, [Git](https://git-scm.com/)
, [Go](https://go.dev/)
, and [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass)
are commonly used when working with Hugo.
Git is required to:
* Build Hugo from source
* Use the [Hugo Modules](https://gohugo.io/hugo-modules/)
feature
* Install a theme as a Git submodule
* Access [commit information](https://gohugo.io/methods/page/gitinfo/)
from a local Git repository
* Host your site on [CI/CD](https://gohugo.io/quick-reference/glossary/#cicd)
platforms such as [Cloudflare](https://gohugo.io/host-and-deploy/host-on-cloudflare/)
, [GitHub Pages](https://gohugo.io/host-and-deploy/host-on-github-pages/)
, [GitLab Pages](https://gohugo.io/host-and-deploy/host-on-gitlab-pages/)
, [Netlify](https://gohugo.io/host-and-deploy/host-on-netlify/)
, [Render](https://gohugo.io/host-and-deploy/host-on-render/)
, or [Vercel](https://gohugo.io/host-and-deploy/host-on-vercel/)
Go is required to:
* Build Hugo from source
* Use the Hugo Modules feature
Dart Sass is required to transpile Sass to CSS when using the latest features of the Sass language.
Please refer to the relevant documentation for installation instructions:
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [Go](https://go.dev/doc/install)
* [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass)
Prebuilt binaries
-----------------
Prebuilt binaries are available for a variety of operating systems and architectures. Visit the [latest release](https://github.com/gohugoio/hugo/releases/latest)
page, and scroll down to the Assets section.
1. Download the archive for the desired edition, operating system, and architecture
2. Extract the archive
3. Move the executable to the desired directory
4. Add this directory to the PATH environment variable
5. Verify that you have _execute_ permission on the file
Please consult your operating system documentation if you need help setting file permissions or modifying your PATH environment variable.
If you do not see a prebuilt binary for the desired edition, operating system, and architecture, install Hugo using one of the methods described below.
Repository packages
-------------------
Most BSD derivatives maintain a repository for commonly installed applications. Please note that these repositories may not contain the [latest release](https://github.com/gohugoio/hugo/releases/latest)
.
### DragonFly BSD
[DragonFly BSD](https://www.dragonflybsd.org/)
includes Hugo in its package repository. To install the extended edition of Hugo:
sudo pkg install gohugo
### FreeBSD
[FreeBSD](https://www.freebsd.org/)
includes Hugo in its package repository. To install the extended edition of Hugo:
sudo pkg install gohugo
### NetBSD
[NetBSD](https://www.netbsd.org/)
includes Hugo in its package repository. To install the extended edition of Hugo:
sudo pkgin install go-hugo
### OpenBSD
[OpenBSD](https://www.openbsd.org/)
includes Hugo in its package repository. This will prompt you to select which edition of Hugo to install:
doas pkg_add hugo
Build from source
-----------------
To build the extended or extended/deploy edition from source you must:
1. Install [Git](https://git-scm.com/)
2. Install [Go](https://go.dev/)
version 1.24.0 or later
3. Install a C compiler, either [GCC](https://gcc.gnu.org/)
or [Clang](https://clang.llvm.org/)
4. Update your `PATH` environment variable as described in the [Go documentation](https://go.dev/doc/code#Command)
> The install directory is controlled by the `GOPATH` and `GOBIN` environment variables. If `GOBIN` is set, binaries are installed to that directory. If `GOPATH` is set, binaries are installed to the bin subdirectory of the first directory in the `GOPATH` list. Otherwise, binaries are installed to the bin subdirectory of the default `GOPATH` (`$HOME/go` or `%USERPROFILE%\go`).
To build the standard edition:
go install github.com/gohugoio/hugo@latest
To build the extended edition:
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest
To build the extended/deploy edition:
CGO_ENABLED=1 go install -tags extended,withdeploy github.com/gohugoio/hugo@latest
Comparison
----------
| | Prebuilt binaries | Repository packages | Build from source |
| --- | --- | --- | --- |
| Easy to install? | ✔️ | ✔️ | ✔️ |
| Easy to upgrade? | ✔️ | varies | ✔️ |
| Easy to downgrade? | ✔️ | varies | ✔️ |
| Automatic updates? | ❌ | varies | ❌ |
| Latest version available? | ✔️ | varies | ✔️ |
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/installation/bsd.md)
---
# Windows
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Install Hugo on Windows.
Hugo v0.121.1 and later require at least Windows 10 or Windows Server 2016.
Editions
--------
Hugo offers a standard edition with core features, plus extended and extended/deploy editions with more. Use the standard edition unless you need the features below.
| Feature | extended edition | extended/deploy edition |
| --- | --- | --- |
| [Transpile Sass to CSS](https://gohugo.io/functions/css/sass/) via embedded LibSass. Note that embedded LibSass was deprecated in v0.153.0 and will be removed in a future release. Use the [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass) transpiler instead, which is compatible with any edition. | ✔️ | ✔️ |
| Deploy your site directly to a Google Cloud Storage bucket, an AWS S3 bucket, or an Azure Storage container. See [details](https://gohugo.io/host-and-deploy/deploy-with-hugo-deploy/) . | ❌ | ✔️ |
Prerequisites
-------------
Although not required in all cases, [Git](https://git-scm.com/)
, [Go](https://go.dev/)
, and [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass)
are commonly used when working with Hugo.
Git is required to:
* Build Hugo from source
* Use the [Hugo Modules](https://gohugo.io/hugo-modules/)
feature
* Install a theme as a Git submodule
* Access [commit information](https://gohugo.io/methods/page/gitinfo/)
from a local Git repository
* Host your site on [CI/CD](https://gohugo.io/quick-reference/glossary/#cicd)
platforms such as [Cloudflare](https://gohugo.io/host-and-deploy/host-on-cloudflare/)
, [GitHub Pages](https://gohugo.io/host-and-deploy/host-on-github-pages/)
, [GitLab Pages](https://gohugo.io/host-and-deploy/host-on-gitlab-pages/)
, [Netlify](https://gohugo.io/host-and-deploy/host-on-netlify/)
, [Render](https://gohugo.io/host-and-deploy/host-on-render/)
, or [Vercel](https://gohugo.io/host-and-deploy/host-on-vercel/)
Go is required to:
* Build Hugo from source
* Use the Hugo Modules feature
Dart Sass is required to transpile Sass to CSS when using the latest features of the Sass language.
Please refer to the relevant documentation for installation instructions:
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [Go](https://go.dev/doc/install)
* [Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass)
Prebuilt binaries
-----------------
Prebuilt binaries are available for a variety of operating systems and architectures. Visit the [latest release](https://github.com/gohugoio/hugo/releases/latest)
page, and scroll down to the Assets section.
1. Download the archive for the desired edition, operating system, and architecture
2. Extract the archive
3. Move the executable to the desired directory
4. Add this directory to the PATH environment variable
5. Verify that you have _execute_ permission on the file
Please consult your operating system documentation if you need help setting file permissions or modifying your PATH environment variable.
If you do not see a prebuilt binary for the desired edition, operating system, and architecture, install Hugo using one of the methods described below.
Package managers
----------------
### Chocolatey
[Chocolatey](https://chocolatey.org/)
is a free and open-source package manager for Windows. To install the extended edition of Hugo:
choco install hugo-extended
### Scoop
[Scoop](https://scoop.sh/)
is a free and open-source package manager for Windows. To install the extended edition of Hugo:
scoop install hugo-extended
### Winget
[Winget](https://learn.microsoft.com/en-us/windows/package-manager/)
is Microsoft’s official free and open-source package manager for Windows. To install the extended edition of Hugo:
winget install Hugo.Hugo.Extended
To uninstall the extended edition of Hugo:
winget uninstall --name "Hugo (Extended)"
Build from source
-----------------
To build the extended or extended/deploy edition from source you must:
1. Install [Git](https://git-scm.com/)
2. Install [Go](https://go.dev/)
version 1.24.0 or later
3. Install a C compiler, either [GCC](https://gcc.gnu.org/)
or [Clang](https://clang.llvm.org/)
4. Update your `PATH` environment variable as described in the [Go documentation](https://go.dev/doc/code#Command)
> The install directory is controlled by the `GOPATH` and `GOBIN` environment variables. If `GOBIN` is set, binaries are installed to that directory. If `GOPATH` is set, binaries are installed to the bin subdirectory of the first directory in the `GOPATH` list. Otherwise, binaries are installed to the bin subdirectory of the default `GOPATH` (`$HOME/go` or `%USERPROFILE%\go`).
To build the standard edition:
go install github.com/gohugoio/hugo@latest
To build the extended edition:
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest
To build the extended/deploy edition:
CGO_ENABLED=1 go install -tags extended,withdeploy github.com/gohugoio/hugo@latest
See these [detailed instructions](https://discourse.gohugo.io/t/41370)
to install GCC on Windows.
Comparison
----------
| | Prebuilt binaries | Package managers | Build from source |
| --- | --- | --- | --- |
| Easy to install? | ✔️ | ✔️ | ✔️ |
| Easy to upgrade? | ✔️ | ✔️ | ✔️ |
| Easy to downgrade? | ✔️ | ✔️ [1](https://gohugo.io/installation/windows/#fn:1) | ✔️ |
| Automatic updates? | ❌ | ❌ [2](https://gohugo.io/installation/windows/#fn:2) | ❌ |
| Latest version available? | ✔️ | ✔️ | ✔️ |
* * *
1. Easy if a previous version is still installed. [↩︎](https://gohugo.io/installation/windows/#fnref:1)
2. Possible but requires advanced configuration. [↩︎](https://gohugo.io/installation/windows/#fnref:2)
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/installation/windows.md)
---
# Sitemap templates
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hugo provides built-in sitemap templates.
Overview
--------
Hugo’s embedded sitemap templates conform to v0.9 of the [sitemap protocol](https://www.sitemaps.org/protocol.html)
.
With a monolingual project, Hugo generates a sitemap.xml file in the root of the [`publishDir`](https://gohugo.io/configuration/all/#publishdir)
using the [embedded sitemap template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/sitemap.xml)
.
With a multilingual project, Hugo generates:
* A sitemap.xml file in the root of each site (language) using the [embedded sitemap template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/sitemap.xml)
* A sitemap.xml file in the root of the [`publishDir`](https://gohugo.io/configuration/all/#publishdir)
using the [embedded sitemapindex template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/sitemapindex.xml)
Configuration
-------------
See [configure sitemap](https://gohugo.io/configuration/sitemap/)
.
Override default values
-----------------------
Override the default values for a given page in front matter.
---
sitemap:
changefreq: weekly
disable: true
priority: 0.8
title: News
---
+++
title = 'News'
[sitemap]
changefreq = 'weekly'
disable = true
priority = 0.8
+++
{
"sitemap": {
"changefreq": "weekly",
"disable": true,
"priority": 0.8
},
"title": "News"
}
Override built-in templates
---------------------------
To override the built-in sitemap.xml template, create a new `layouts/sitemap.xml` file. When ranging through the page collection, access the _change frequency_ and _priority_ with `.Sitemap.ChangeFreq` and `.Sitemap.Priority` respectively.
To override the built-in sitemapindex.xml template, create a new `layouts/sitemapindex.xml` file.
Disable sitemap generation
--------------------------
You may disable sitemap generation in your project configuration:
disableKinds:
- sitemap
disableKinds = ['sitemap']
{
"disableKinds": [\
"sitemap"\
]
}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/sitemap.md)
---
# Abs
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the absolute value of the given time.Duration value.
Syntax
DURATION.Abs
Returns
time.Duration
{{ $d = time.ParseDuration "-3h" }}
{{ $d.Abs }} → 3h0m0s
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/duration/Abs.md)
---
# Custom 404 page
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Create a template to render a 404 error page.
To render a 404 error page in the root of your site, create a 404 template in the root of the `layouts` directory. For example:
layouts/404.html
{{ define "main" }}
{{- end }}
{{- end }}
Call the partial above, passing a menu ID and the current page in context.
layouts/page.html
{{ partial "menu.html" (dict "menuID" "main" "page" .) }}
{{ partial "menu.html" (dict "menuID" "footer" "page" .) }}
Page references
---------------
Regardless of how you [define menu entries](https://gohugo.io/content-management/menus/)
, an entry associated with a page has access to page context.
This simplistic example renders a page parameter named `version` next to each entry’s `name`. Code defensively using `with` or `if` to handle entries where (a) the entry points to an external resource, or (b) the `version` parameter is not defined.
layouts/page.html
{{- range site.Menus.main }}
{{ .Name }}
{{- with .Page }}
{{- with .Params.version -}}
({{ . }})
{{- end }}
{{- end }}
{{- end }}
Menu entry parameters
---------------------
When you define menu entries in your [project configuration](https://gohugo.io/content-management/menus/#define-in-project-configuration)
or in [front matter](https://gohugo.io/content-management/menus/#define-in-front-matter)
, you can include a `params` key as shown in these examples:
* [Menu entry defined in your project configuration](https://gohugo.io/configuration/menus/)
* [Menu entry defined in front matter](https://gohugo.io/content-management/menus/#example)
This simplistic example renders a `class` attribute for each anchor element. Code defensively using `with` or `if` to handle entries where `params.class` is not defined.
layouts/\_partials/menu.html
{{- range site.Menus.main }}
{{ .Name }}
{{- end }}
Localize
--------
Hugo provides two methods to localize your menu entries. See [multilingual](https://gohugo.io/content-management/multilingual/#menus)
.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/menu.md)
---
# robots.txt template
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hugo can generate a customized robots.txt in the same way as any other template.
To generate a robots.txt file from a template, change your [project configuration](https://gohugo.io/configuration/)
:
enableRobotsTXT: true
enableRobotsTXT = true
{
"enableRobotsTXT": true
}
By default, Hugo generates robots.txt using an [embedded template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/robots.txt)
.
User-agent: *
Search engines that honor the Robots Exclusion Protocol will interpret this as permission to crawl everything on the site.
robots.txt template lookup order
--------------------------------
You may overwrite the internal template with a custom template. Hugo selects the template using this lookup order:
1. `/layouts/robots.txt`
2. `/themes//layouts/robots.txt`
robots.txt template example
---------------------------
layouts/robots.txt
User-agent: *
{{ range .Pages }}
Disallow: {{ .RelPermalink }}
{{ end }}
This template creates a robots.txt file with a `Disallow` directive for each page on the site. Search engines that honor the Robots Exclusion Protocol will not crawl any page on the site.
To create a robots.txt file without using a template:
1. Set `enableRobotsTXT` to `false` in your project configuration.
2. Create a robots.txt file in the `static` directory.
Remember that Hugo copies everything in the static director to the root of `publishDir` (typically `public`) when you build your project.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/robots.md)
---
# Categories
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
---
# Alphabetical
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns an ordered taxonomy, sorted alphabetically by term.
Syntax
TAXONOMY.Alphabetical
Returns
page.OrderedTaxonomy
The `Alphabetical` method on a `Taxonomy` object returns an [ordered taxonomy](https://gohugo.io/quick-reference/glossary/#ordered-taxonomy)
, sorted alphabetically by [term](https://gohugo.io/quick-reference/glossary/#term)
.
While a `Taxonomy` object is a [map](https://gohugo.io/quick-reference/glossary/#map)
, an ordered taxonomy is a [slice](https://gohugo.io/quick-reference/glossary/#slice)
, where each element is an object that contains the term and a slice of its [weighted pages](https://gohugo.io/quick-reference/glossary/#weighted-page)
.
Before we can use a `Taxonomy` method, we need to capture a `Taxonomy` object.
Capture a Taxonomy object
-------------------------
Consider this project configuration:
taxonomies:
author: authors
genre: genres
[taxonomies]
author = 'authors'
genre = 'genres'
{
"taxonomies": {
"author": "authors",
"genre": "genres"
}
}
And this content structure:
content/
├── books/
│ ├── and-then-there-were-none.md --> genres: suspense
│ ├── death-on-the-nile.md --> genres: suspense
│ └── jamaica-inn.md --> genres: suspense, romance
│ └── pride-and-prejudice.md --> genres: romance
└── _index.md
To capture the “genres” `Taxonomy` object from within any template, use the [`Taxonomies`](https://gohugo.io/methods/site/taxonomies/)
method on a `Site` object.
{{ $taxonomyObject := .Site.Taxonomies.genres }}
To capture the “genres” `Taxonomy` object when rendering its page with a _taxonomy_ template, use the [`Terms`](https://gohugo.io/methods/page/data/#in-a-taxonomy-template)
method on the page’s [`Data`](https://gohugo.io/methods/page/data/)
object:
layouts/taxonomy.html
{{ $taxonomyObject := .Data.Terms }}
To inspect the data structure:
{{ debug.Dump $taxonomyObject }}
Although the [`Alphabetical`](https://gohugo.io/methods/taxonomy/alphabetical/)
and [`ByCount`](https://gohugo.io/methods/taxonomy/bycount/)
methods provide a better data structure for ranging through the taxonomy, you can render the weighted pages by term directly from the `Taxonomy` object:
{{ range $term, $weightedPages := $taxonomyObject }}
{{ end }}
In the example above, the first anchor element is a link to the term page.
Get the ordered taxonomy
------------------------
Now that we have captured the “genres” Taxonomy object, let’s get the ordered taxonomy sorted alphabetically by term:
{{ $taxonomyObject.Alphabetical }}
To reverse the sort order:
{{ $taxonomyObject.Alphabetical.Reverse }}
To inspect the data structure:
{{ debug.Dump $taxonomyObject.Alphabetical }}
An ordered taxonomy is a slice, where each element is an object that contains the term and a slice of its weighted pages.
Each element of the slice provides these methods:
Count
(`int`) Returns the number of pages to which the term is assigned.
Page
(`page.Page`) Returns the term’s `Page` object, useful for linking to the term page.
Pages
(`page.Pages`) Returns a `Pages` object containing the `Page` objects to which the term is assigned, sorted by [taxonomic weight](https://gohugo.io/quick-reference/glossary/#taxonomic-weight)
. To sort or group, use any of the [methods](https://gohugo.io/methods/pages/)
available to the `Pages` object. For example, sort by the last modification date.
Term
(`string`) Returns the term name.
WeightedPages
(`page.WeightedPages`) Returns a slice of weighted pages to which the term is assigned, sorted by taxonomic weight. The `Pages` method above is more flexible, allowing you to sort and group.
Example
-------
With this template:
{{ range $taxonomyObject.Alphabetical }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/taxonomy/Alphabetical.md)
---
# Partial decorators
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Use partial decorators to create reusable wrapper components that enclose and compose template content.
[New in v0.154.0](https://github.com/gohugoio/hugo/releases/tag/v0.154.0)
Overview
--------
A _partial decorator_ is specific type of [_partial_](https://gohugo.io/quick-reference/glossary/#partial)
that functions as a [_wrapper component_](https://gohugo.io/quick-reference/glossary/#wrapper-component)
. While a standard partial simply renders data within a fixed template, a decorator uses composition to enclose an entire block of content. It utilizes the [`templates.Inner`](https://gohugo.io/functions/templates/inner/)
function as a placeholder to define exactly where that external content should be injected within the wrapper’s layout.
This approach creates a connection between two files. The calling template provides a block of code and the partial decorator determines where that code appears. This allows the partial to wrap around content without needing to know the specific markup or internal logic of the enclosed block.
Implementation
--------------
To use a partial decorator, use a block-style call in your templates. The [`with`](https://gohugo.io/functions/go-template/with/)
statement is required to initiate the partial and create a container for the content. This block can include any valid template code including page methods and functions.
layouts/home.html
{{ with partial "components/wrapper.html" . }}
{{ end }}
Inside the partial template, place the `templates.Inner` function call where the wrapped content should appear.
layouts/\_partials/components/wrapper.html
{{ templates.Inner . }}
The `with` statement creates a new [scope](https://gohugo.io/quick-reference/glossary/#scope)
. Variables defined outside of the `with` block are not available inside it. To use external data within the wrapped content, you must ensure it is part of the [context](https://gohugo.io/quick-reference/glossary/#context)
passed in the partial call.
A key feature of the `templates.Inner` function is its ability to accept a context argument. By passing a context to the function, you define what the dot (`.`) represents inside the wrapped block. This ensures that the injected content has access to the correct data even when nested inside multiple layers of wrappers.
Benefits of composition
-----------------------
Using partial decorators to build wrapper components provides several advantages:
* It eliminates the need to use separate partials for opening and closing tags when encapsulating a block of code.
* It prevents parameter bloat because a standard partial no longer requires an extensive list of arguments to account for every possible variation of the content inside it.
* It enables clean composition where the wrapped block can execute any template logic without the wrapper needing to receive or process that data.
This approach separates container logic from content logic. The wrapper handles structural requirements like specific class hierarchies or CSS grid containers. The calling template retains control over the inner markup and how data is displayed.
Example
-------
The following templates illustrate how to nest three wrapper components including a section, a column, and a card while passing context through each layer.
The home template initiates the structure by calling the section, column, and card partials as decorators:
layouts/home.html
{{ $ctx := dict
"page" .
"label" "Recent Posts"
"pageCollection" ((site.GetPage "/posts").RegularPages)
}}
{{ with partial "components/section.html" $ctx }}
{{ range .pageCollection }}
{{ with partial "components/column.html" (dict "page" . "class" "col-half") }}
{{ with partial "components/card.html" (dict "page" .page "url" .page.RelPermalink "title" .page.LinkTitle) }}
{{ end }}
The section component provides a semantic container and an optional heading:
layouts/\_partials/components/section.html
{{ with .label }}
{{ . }}
{{ end }}
{{ templates.Inner . }}
The column component manages layout width by applying a CSS class:
layouts/\_partials/components/column.html
{{ templates.Inner . }}
The card component defines the visual boundary for the content:
layouts/\_partials/components/card.html
{{ with .title }}
{{ if $.url }}
{{ . }}
{{ else }}
{{ . }}
{{ end }}
{{ end }}
{{ templates.Inner . }}
{{ with .url }}
{{ end }}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/partial-decorators.md)
---
# Minify
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Minify a given resource.
See the [`resources.Minify`](https://gohugo.io/functions/resources/minify/)
function.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/hugo-pipes/minification.md)
---
# Template types
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Create templates of different types to render your content, resources, and data.
Structure
---------
Create templates in the `layouts` directory in the root of your project.
Although your site may not require each of these templates, the example below is typical for a site of medium complexity.
layouts/
├── _markup/
│ ├── render-image.html <-- render hook
│ └── render-link.html <-- render hook
├── _partials/
│ ├── footer.html
│ └── header.html
├── _shortcodes/
│ ├── audio.html
│ └── video.html
├── books/
│ ├── page.html
│ └── section.html
├── films/
│ ├── view_card.html <-- content view
│ ├── view_li.html <-- content view
│ ├── page.html
│ └── section.html
├── baseof.html
├── home.html
├── page.html
├── section.html
├── taxonomy.html
└── term.html
Hugo’s [template lookup order](https://gohugo.io/templates/lookup-order/)
determines the template path, allowing you to create unique templates for any page.
You must have thorough understanding of the template lookup order when creating templates. Template selection is based on template type, page kind, content type, section, language, and output format.
The purpose of each template type is described below.
Base
----
A _base_ template serves as a foundational layout that other templates can build upon. It typically defines the common structural components of your HTML, such as the `html`, `head`, and `body` elements. It also often includes recurring features like headers, footers, navigation, and script inclusions that appear across multiple pages of your site. By defining these common aspects once in a _base_ template, you avoid redundancy, ensure consistency, and simplify the maintenance of your website.
Hugo can apply a _base_ template to the following template types: [home](https://gohugo.io/templates/types/#home)
, [page](https://gohugo.io/templates/types/#page)
, [section](https://gohugo.io/templates/types/#section)
, [taxonomy](https://gohugo.io/templates/types/#taxonomy)
, [term](https://gohugo.io/templates/types/#term)
, [single](https://gohugo.io/templates/types/#single)
, [list](https://gohugo.io/templates/types/#list)
, and [all](https://gohugo.io/templates/types/#all)
. When Hugo parses any of these template types, it will apply a _base_ template only if the template being parsed meets these specific conditions:
* It must include at least one [`define`](https://gohugo.io/functions/go-template/define/)
[action](https://gohugo.io/quick-reference/glossary/#action)
.
* It can only contain `define` actions, whitespace, and [template comments](https://gohugo.io/templates/introduction/#comments)
. No other content is allowed.
If a template doesn’t meet all these criteria, Hugo executes it exactly as provided, without applying a _base_ template.
When Hugo applies a _base_ template, it replaces its [`block`](https://gohugo.io/functions/go-template/block/)
actions with content from the corresponding `define` actions found in the template to which the base template is applied.
For example, the _base_ template below calls the [`partial`](https://gohugo.io/functions/partials/include/)
function to include `head`, `header`, and `footer` elements. The `block` action acts as a placeholder, and its content will be replaced by a matching `define` action from the template to which it is applied.
layouts/baseof.html
{{ partial "head.html" . }}
{{ partial "header.html" . }}
{{ block "main" . }}
This will be replaced with content from the
corresponding "define" action found in the template
to which this base template is applied.
{{ end }}
layouts/home.html
{{ define "main" }}
This will replace the content of the "block" action
found in the base template.
{{ end }}
Home
----
A _home_ template renders your site’s home page.
For example, Hugo applies a _base_ template to the _home_ template below, then renders the page content and a list of the site’s regular pages.
layouts/home.html
{{ define "main" }}
{{ .Content }}
{{ range .Site.RegularPages }}
{{ end }}
{{ end }}
The [page collections quick reference guide](https://gohugo.io/quick-reference/page-collections/)
describes methods and functions to filter, sort, and group page collections.
Page
----
A _page_ template renders a regular page.
For example, Hugo applies a _base_ template to the _page_ template below, then renders the page title and page content.
layouts/page.html
{{ define "main" }}
{{ .Title }}
{{ .Content }}
{{ end }}
Section
-------
A _section_ template renders a list of pages within a [section](https://gohugo.io/quick-reference/glossary/#section)
.
For example, Hugo applies a _base_ template to the _section_ template below, then renders the page title, page content, and a list of pages in the current section.
layouts/section.html
{{ define "main" }}
{{ end }}
{{ end }}
The [page collections quick reference guide](https://gohugo.io/quick-reference/page-collections/)
describes methods and functions to filter, sort, and group page collections.
Taxonomy
--------
A _taxonomy_ template renders a list of terms in a [taxonomy](https://gohugo.io/quick-reference/glossary/#taxonomy)
.
For example, Hugo applies a _base_ template to the _taxonomy_ template below, then renders the page title, page content, and a list of [terms](https://gohugo.io/quick-reference/glossary/#term)
in the current taxonomy.
layouts/taxonomy.html
{{ define "main" }}
{{ end }}
{{ end }}
The [page collections quick reference guide](https://gohugo.io/quick-reference/page-collections/)
describes methods and functions to filter, sort, and group page collections.
Within a _taxonomy_ template, the [`Data`](https://gohugo.io/methods/page/data/)
object provides these taxonomy-specific methods:
* [`Singular`](https://gohugo.io/methods/page/data/#singular)
* [`Plural`](https://gohugo.io/methods/page/data/#plural)
* [`Terms`](https://gohugo.io/methods/page/data/#terms)
The `Terms` method returns a [taxonomy object](https://gohugo.io/quick-reference/glossary/#taxonomy-object)
, allowing you to call any of its methods including [`Alphabetical`](https://gohugo.io/methods/taxonomy/alphabetical/)
and [`ByCount`](https://gohugo.io/methods/taxonomy/bycount/)
. For example, use the `ByCount` method to render a list of terms sorted by the number of pages associated with each term:
layouts/taxonomy.html
{{ define "main" }}
{{ end }}
{{ end }}
Term
----
A _term_ template renders a list of pages associated with a [term](https://gohugo.io/quick-reference/glossary/#term)
.
For example, Hugo applies a _base_ template to the _term_ template below, then renders the page title, page content, and a list of pages associated with the current term.
layouts/term.html
{{ define "main" }}
{{ end }}
{{ end }}
The [page collections quick reference guide](https://gohugo.io/quick-reference/page-collections/)
describes methods and functions to filter, sort, and group page collections.
Within a _term_ template, the [`Data`](https://gohugo.io/methods/page/data/)
object provides these term-specific methods:
* [`Singular`](https://gohugo.io/methods/page/data/#singular-1)
* [`Plural`](https://gohugo.io/methods/page/data/#plural-1)
* [`Term`](https://gohugo.io/methods/page/data/#term)
Single
------
A _single_ template is a fallback for a _page_ template. If a _page_ template does not exist, Hugo will look for a _single_ template instead.
For example, Hugo applies a _base_ template to the _single_ template below, then renders the page title and page content.
layouts/single.html
{{ define "main" }}
{{ .Title }}
{{ .Content }}
{{ end }}
List
----
A _list_ template is a fallback for [home](https://gohugo.io/templates/types/#home)
, [section](https://gohugo.io/templates/types/#section)
, [taxonomy](https://gohugo.io/templates/types/#taxonomy)
, and [term](https://gohugo.io/templates/types/#term)
templates. If one of these template types does not exist, Hugo will look for a _list_ template instead.
For example, Hugo applies a _base_ template to the _list_ template below, then renders the page title, page content, and a list of pages.
layouts/list.html
{{ define "main" }}
{{ end }}
{{ end }}
All
---
An _all_ template is a fallback for [home](https://gohugo.io/templates/types/#home)
, [page](https://gohugo.io/templates/types/#page)
, [section](https://gohugo.io/templates/types/#section)
, [taxonomy](https://gohugo.io/templates/types/#taxonomy)
, [term](https://gohugo.io/templates/types/#term)
, [single](https://gohugo.io/templates/types/#single)
, and [list](https://gohugo.io/templates/types/#list)
templates. If one of these template types does not exist, Hugo will look for an _all_ template instead.
For example, Hugo applies a _base_ template to the _all_ template below, then conditionally renders a page based on its page kind.
layouts/all.html
{{ define "main" }}
{{ if eq .Kind "home" }}
{{ .Content }}
{{ range .Site.RegularPages }}
{{ end }}
{{ else }}
{{ errorf "Unsupported page kind: %s" .Kind }}
{{ end }}
{{ end }}
Partial
-------
A _partial_ template is typically used to render a component of your site, though you may also create _partial_ templates that return values.
For example, the _partial_ template below renders copyright information:
layouts/\_partials/footer.html
Copyright {{ now.Year }}. All rights reserved.
Execute the _partial_ template by calling the [`partial`](https://gohugo.io/functions/partials/include/)
or [`partialCached`](https://gohugo.io/functions/partials/includecached/)
function, optionally passing context as the second argument:
layouts/baseof.html
{{ partial "footer.html" . }}
Unlike other template types, Hugo does not consider the current page kind, content type, logical path, language, or output format when searching for a matching _partial_ template. However, it _does_ apply the same _name_ matching logic it uses for other template types. This means it tries to find the most specific match first, then progressively looks for more general versions if the specific one isn’t found.
For example, with this call:
layouts/baseof.html
{{ partial "footer.section.de.html" . }}
Hugo uses this lookup order to find a matching template:
1. `layouts/_partials/footer.section.de.html`
2. `layouts/_partials/footer.section.html`
3. `layouts/_partials/footer.de.html`
4. `layouts/_partials/footer.html`
A _partial_ template can also be defined inline within another template. However, it’s important to note that the template namespace is global; ensuring unique names for these _partial_ templates is necessary to prevent conflicts.
Value: {{ partial "my-inline-partial.html" . }}
{{ define "_partials/my-inline-partial.html" }}
{{ $value := 32 }}
{{ return $value }}
{{ end }}
Content view
------------
A _content view_ template is similar to a _partial_ template, invoked by calling the [`Render`](https://gohugo.io/methods/page/render/)
method on a `Page` object. Unlike _partial_ templates, _content view_ templates:
* Inherit the context of the current page
* Can target any page kind, content type, logical path, language, or output format
* Can reside at any level within the `layouts` directory
For example, Hugo applies a _base_ template to the _home_ template below, then renders the page content and a card component for each page within the “films” section of your site.
layouts/home.html
{{ define "main" }}
{{ .Content }}
{{ range where site.RegularPages "Section" "films" }}
{{ .Render "view_card" }}
{{ end }}
In the example above, the content view template’s name starts with `view_`. While not strictly required, this naming convention helps distinguish content view templates from other templates within the same directory, improving organization and clarity.
Render hook
-----------
A _render hook_ template overrides the conversion of Markdown to HTML.
For example, the _render hook_ template below adds an anchor link to the right of each heading.
layouts/\_markup/render-heading.html
{{ .Text }}
#
Learn more about [render hook templates](https://gohugo.io/render-hooks/)
.
Shortcode
---------
A _shortcode_ template is used to render a component of your site. Unlike _partial_ or _content view_ templates, _shortcode_ templates are called from content pages.
For example, the _shortcode_ template below renders an audio element from a [global resource](https://gohugo.io/quick-reference/glossary/#global-resource)
.
layouts/\_shortcodes/audio.html
{{ with resources.Get (.Get "src") }}
{{ end }}
Then call the shortcode from within markup:
content/example.md
{{< audio src=/audio/test.mp3 >}}
Learn more about [shortcode templates](https://gohugo.io/templates/shortcode/)
.
Other
-----
Use other specialized templates to create:
* [Sitemaps](https://gohugo.io/templates/sitemap/)
* [RSS feeds](https://gohugo.io/templates/rss/)
* [404 error pages](https://gohugo.io/templates/404/)
* [robots.txt files](https://gohugo.io/templates/robots/)
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/types.md)
---
# Introduction to templating
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

An introduction to Hugo’s templating syntax.
We did a complete overhaul of Hugo’s template system in v0.146.0. We’re working on getting all of the relevant documentation up to date, but until then, see [this page](https://gohugo.io/templates/new-templatesystem-overview/)
.
A _template_ is a file with [_template actions_](https://gohugo.io/quick-reference/glossary/#template-action)
, located within the `layouts` directory of a project, theme, or module.
Templates use [variables](https://gohugo.io/templates/introduction/#variables)
, [functions](https://gohugo.io/functions/)
, and [methods](https://gohugo.io/methods/)
to transform your content, resources, and data into a published page.
Hugo uses Go’s [`text/template`](https://pkg.go.dev/text/template)
and [`html/template`](https://pkg.go.dev/html/template)
packages.
The `text/template` package implements data-driven templates for generating textual output, while the `html/template` package implements data-driven templates for generating HTML output safe against code injection.
By default, Hugo uses the `html/template` package when rendering HTML files.
For example, this HTML template initializes the `$v1` and `$v2` variables, then displays them and their product within an HTML paragraph.
{{ $v1 := 6 }}
{{ $v2 := 7 }}
The product of {{ $v1 }} and {{ $v2 }} is {{ mul $v1 $v2 }}.
While HTML templates are the most common, you can create templates for any [output format](https://gohugo.io/quick-reference/glossary/#output-format)
including CSV, JSON, RSS, and plain text.
Context
-------
The most important concept to understand before creating a template is _context_, the data passed into each template. The data may be a simple value, or more commonly [objects](https://gohugo.io/quick-reference/glossary/#object)
and associated [methods](https://gohugo.io/quick-reference/glossary/#method)
.
For example, a _page_ template receives a `Page` object, and the `Page` object provides methods to return values or perform actions.
### Current context
Within a template, the dot (`.`) represents the current context.
layouts/page.html
{{ .Title }}
In the example above the dot represents the `Page` object, and we call its [`Title`](https://gohugo.io/methods/page/title/)
method to return the title as defined in [front matter](https://gohugo.io/content-management/front-matter/)
.
The current context may change within a template. For example, at the top of a template the context might be a `Page` object, but we rebind the context to another value or object within [`range`](https://gohugo.io/functions/go-template/range/)
or [`with`](https://gohugo.io/functions/go-template/with/)
blocks.
layouts/page.html
{{ .Title }}
{{ range slice "foo" "bar" }}
{{ . }}
{{ end }}
{{ with "baz" }}
{{ . }}
{{ end }}
In the example above, the context changes as we `range` through the [slice](https://gohugo.io/quick-reference/glossary/#slice)
of values. In the first iteration the context is “foo”, and in the second iteration the context is “bar”. Inside of the `with` block the context is “baz”. Hugo renders the above to:
My Page Title
foo
bar
baz
### Template context
Within a `range` or `with` block you can access the context passed into the template by prepending a dollar sign (`$`) to the dot:
layouts/page.html
{{ with "foo" }}
{{ $.Title }} - {{ . }}
{{ end }}
Hugo renders this to:
My Page Title - foo
Make sure that you thoroughly understand the concept of _context_ before you continue reading. The most common templating errors made by new users relate to context.
Actions
-------
In the examples above, the paired opening and closing braces represent the beginning and end of a template action, a data evaluation or control structure within a template.
A template action may contain literal values ([boolean](https://gohugo.io/quick-reference/glossary/#boolean)
, [string](https://gohugo.io/quick-reference/glossary/#string)
, [integer](https://gohugo.io/quick-reference/glossary/#integer)
, and [float](https://gohugo.io/quick-reference/glossary/#float)
), the [current context](https://gohugo.io/templates/introduction/#current-context)
, [variables](https://gohugo.io/templates/introduction/#variables)
, [functions](https://gohugo.io/templates/introduction/#functions)
, [methods](https://gohugo.io/templates/introduction/#methods)
, and the [`nil`](https://gohugo.io/templates/introduction/#nil)
keyword.
layouts/page.html
{{ $convertToLower := true }}
{{ if $convertToLower }}
{{ strings.ToLower .Title }}
{{ end }}
In the example above:
* `$convertToLower` is a variable
* `true` is a literal boolean value
* `if` is the beginning of a control structure
* `strings.ToLower` is a function that converts all characters to lowercase
* `Title` is a method on a the `Page` object
* `end` is the end of a control structure
Hugo renders the above to:
my page title
### Whitespace
Notice the blank lines and indentation in the previous example? Although irrelevant in production when you typically minify the output, you can remove the adjacent whitespace by using template action delimiters with hyphens:
layouts/page.html
{{- $convertToLower := true -}}
{{- if $convertToLower -}}
{{ strings.ToLower .Title }}
{{- end -}}
Hugo renders this to:
my page title
Whitespace includes spaces, horizontal tabs, carriage returns, and newlines.
### Quote characters
Hugo templates use different quote characters to define how text and characters are processed.
Use double quotes for [interpreted string literals](https://gohugo.io/quick-reference/glossary/#interpreted-string-literal)
. These interpret backslashes as special instructions:
{{ print "Hello world\u0021" }} → Hello world!
Use backticks for [raw string literals](https://gohugo.io/quick-reference/glossary/#raw-string-literal)
. These ignore backslashes and treat every character literally:
{{ print `Hello world\u0021` }} → Hello world\u0021
Use single quotes for [rune literals](https://gohugo.io/quick-reference/glossary/#rune-literal)
. Unlike strings, these represent a single character as its numerical Unicode value:
{{ print '!' }} → 33
In practical terms, you will rarely, if ever, use rune literals in your template code. They are most commonly used in low-level programming; in a Hugo template, you will almost always want a string instead.
### Pipes
Within a template action you may [pipe](https://gohugo.io/quick-reference/glossary/#pipe)
a value to a function or method. The piped value becomes the final argument to the function or method. For example, these are equivalent:
{{ strings.ToLower "Hugo" }} → hugo
{{ "Hugo" | strings.ToLower }} → hugo
You can pipe the result of one function or method into another. For example, these are equivalent:
{{ strings.TrimSuffix "o" (strings.ToLower "Hugo") }} → hug
{{ "Hugo" | strings.ToLower | strings.TrimSuffix "o" }} → hug
These are also equivalent:
{{ mul 6 (add 2 5) }} → 42
{{ 5 | add 2 | mul 6 }} → 42
Remember that the piped value becomes the final argument to the function or method to which you are piping.
### Line splitting
You can split a template action over two or more lines. For example, these are equivalent:
{{ $v := or $arg1 $arg2 }}
{{ $v := or
$arg1
$arg2
}}
You can also split [raw string literals](https://gohugo.io/quick-reference/glossary/#raw-string-literal)
over two or more lines. For example, these are equivalent:
{{ $msg := "This is line one.\nThis is line two." }}
{{ $msg := `This is line one.
This is line two.`
}}
### Nil
Other than using the `nil` keyword in comparisons, you may not use it as an argument to any function or method, nor may you assign it to a variable. For example, these are valid uses of the `nil` keyword:
{{ if gt 42 nil }}
42 is greater than nil
{{ end }}
{{ $pages := where .Site.RegularPages "Params.color" "ne" nil }}
These, on the other hand, are invalid:
{{ $a := nil }}
{{ add 3 nil }}
{{ nil | print}}
The actions above throw an error.
Variables
---------
A variable is a user-defined [identifier](https://gohugo.io/quick-reference/glossary/#identifier)
prepended with a dollar sign (`$`), representing a value of any data type, initialized or assigned within a template action. For example, `$foo` and `$bar` are variables.
Variables may contain [scalars](https://gohugo.io/quick-reference/glossary/#scalar)
, [slices](https://gohugo.io/quick-reference/glossary/#slice)
, [maps](https://gohugo.io/quick-reference/glossary/#map)
, or [objects](https://gohugo.io/quick-reference/glossary/#object)
.
Use `:=` to initialize a variable, and use `=` to assign a value to a variable that has been previously initialized. For example:
{{ $total := 3 }}
{{ range slice 7 11 21 }}
{{ $total = add $total . }}
{{ end }}
{{ $total }} → 42
Variables initialized inside of an `if`, `range`, or `with` block are scoped to the block. Variables initialized outside of these blocks are scoped to the template.
With variables that represent a slice or map, use the [`index`](https://gohugo.io/functions/collections/indexfunction/)
function to return the desired value.
{{ $slice := slice "foo" "bar" "baz" }}
{{ index $slice 2 }} → baz
{{ $map := dict "a" "foo" "b" "bar" "c" "baz" }}
{{ index $map "c" }} → baz
Slices and arrays are zero-based; element 0 is the first element.
With variables that represent a map or object, [chain](https://gohugo.io/quick-reference/glossary/#chain)
identifiers to return the desired value or to access the desired method.
{{ $map := dict "a" "foo" "b" "bar" "c" "baz" }}
{{ $map.c }} → baz
{{ $homePage := .Site.Home }}
{{ $homePage.Title }} → My Homepage
As seen above, object and method names are capitalized. Although not required, to avoid confusion we recommend beginning variable and map key names with a lowercase letter or underscore.
Functions
---------
Used within a template action, a function takes one or more arguments and returns a value. Unlike methods, functions are not associated with an object.
Go’s `text/template` and `html/template` packages provide a small set of functions, operators, and statements for general use. See the [go-templates](https://gohugo.io/functions/go-template/)
section of the function documentation for details.
Hugo provides hundreds of custom [functions](https://gohugo.io/functions/)
categorized by namespace. For example, the `strings` namespace includes these and other functions:
| Function | Alias |
| --- | --- |
| [`strings.ToLower`](https://gohugo.io/functions/strings/tolower/) | `lower` |
| [`strings.ToUpper`](https://gohugo.io/functions/strings/toupper/) | `upper` |
| [`strings.Replace`](https://gohugo.io/functions/strings/replace/) | `replace` |
As shown above, frequently used functions have an alias. Use aliases in your templates to reduce code length.
When calling a function, separate the arguments from the function, and from each other, with a space. For example:
{{ $total := add 1 2 3 4 }}
Methods
-------
Used within a template action and associated with an object, a method takes zero or more arguments and either returns a value or performs an action.
The most commonly accessed objects are the [`Page`](https://gohugo.io/methods/page/)
and [`Site`](https://gohugo.io/methods/site/)
objects. This is a small sampling of the [methods](https://gohugo.io/methods/)
available to each object.
| Object | Method | Description |
| --- | --- | --- |
| `Page` | [`Date`](https://gohugo.io/methods/page/date/) | Returns the date of the given page. |
| `Page` | [`Params`](https://gohugo.io/methods/page/params/) | Returns a map of custom parameters as defined in the front matter of the given page. |
| `Page` | [`Title`](https://gohugo.io/methods/page/title/) | Returns the title of the given page. |
| `Site` | [`Data`](https://gohugo.io/methods/site/data/) | Returns a data structure composed from the files in the `data` directory. |
| `Site` | [`Params`](https://gohugo.io/methods/site/params/) | Returns a map of custom parameters as defined in your project configuration. |
| `Site` | [`Title`](https://gohugo.io/methods/site/title/) | Returns the title as defined in the your project configuration. |
Chain the method to its object with a dot (`.`) as shown below, remembering that the leading dot represents the [current context](https://gohugo.io/templates/introduction/#current-context)
.
layouts/page.html
{{ .Site.Title }} → My Site Title
{{ .Page.Title }} → My Page Title
The context passed into most templates is a `Page` object, so this is equivalent to the previous example:
layouts/page.html
{{ .Site.Title }} → My Site Title
{{ .Title }} → My Page Title
Some methods take an argument. Separate the argument from the method with a space. For example:
layouts/page.html
{{ $page := .Page.GetPage "/books/les-miserables" }}
{{ $page.Title }} → Les Misérables
Comments
--------
Do not attempt to use HTML comment delimiters to comment out template code.
Hugo strips HTML comments when rendering a page, but first evaluates any template code within the HTML comment delimiters. Depending on the template code within the HTML comment delimiters, this could cause unexpected results or fail the build.
Template comments are similar to template actions. Paired opening and closing braces represent the beginning and end of a comment. For example:
{{/* This is an inline comment. */}}
{{- /* This is an inline comment with adjacent whitespace removed. */ -}}
Code within a comment is not parsed, executed, or displayed. Comments may be inline, as shown above, or in block form:
{{/*
This is a block comment.
*/}}
{{- /*
This is a block comment with
adjacent whitespace removed.
*/ -}}
You may not nest one comment inside of another.
To render an HTML comment, pass a string through the [`safeHTML`](https://gohugo.io/functions/safe/html/)
template function. For example:
{{ "" | safeHTML }}
{{ printf "" .Site.Title | safeHTML }}
Include
-------
Use the [`template`](https://gohugo.io/functions/go-template/template/)
function to include one or more of Hugo’s [embedded templates](https://gohugo.io/templates/embedded/)
:
{{ partial "google_analytics.html" . }}
{{ partial "opengraph" . }}
{{ partial "pagination.html" . }}
{{ partial "schema.html" . }}
{{ partial "twitter_cards.html" . }}
Use the [`partial`](https://gohugo.io/functions/partials/include/)
or [`partialCached`](https://gohugo.io/functions/partials/includecached/)
function to include one or more [partial templates](https://gohugo.io/templates/types/#partial)
:
{{ partial "breadcrumbs.html" . }}
{{ partialCached "css.html" . }}
Create your _partial_ templates in the `layouts/_partials` directory.
In the examples above, note that we are passing the current context (the dot) to each of the templates.
Examples
--------
This limited set of contrived examples demonstrates some of concepts described above. Please see the [functions](https://gohugo.io/functions/)
, [methods](https://gohugo.io/methods/)
, and [templates](https://gohugo.io/templates/)
documentation for specific examples.
### Conditional blocks
See documentation for [`if`](https://gohugo.io/functions/go-template/if/)
, [`else`](https://gohugo.io/functions/go-template/else/)
, and [`end`](https://gohugo.io/functions/go-template/end/)
.
{{ $var := 42 }}
{{ if eq $var 6 }}
{{ print "var is 6" }}
{{ else if eq $var 7 }}
{{ print "var is 7" }}
{{ else if eq $var 42 }}
{{ print "var is 42" }}
{{ else }}
{{ print "var is something else" }}
{{ end }}
### Logical operators
See documentation for [`and`](https://gohugo.io/functions/go-template/and/)
and [`or`](https://gohugo.io/functions/go-template/or/)
.
{{ $v1 := true }}
{{ $v2 := false }}
{{ $v3 := false }}
{{ $result := false }}
{{ if and $v1 $v2 $v3 }}
{{ $result = true }}
{{ end }}
{{ $result }} → false
{{ if or $v1 $v2 $v3 }}
{{ $result = true }}
{{ end }}
{{ $result }} → true
### Loops
See documentation for [`range`](https://gohugo.io/functions/go-template/range/)
, [`else`](https://gohugo.io/functions/go-template/else/)
, and [`end`](https://gohugo.io/functions/go-template/end/)
.
{{ $s := slice "foo" "bar" "baz" }}
{{ range $s }}
{{ . }}
{{ else }}
The collection is empty
{{ end }}
To loop a specified number of times:
{{ $s := slice }}
{{ range 3 }}
{{ $s = $s | append . }}
{{ end }}
{{ $s }} → [0 1 2]
### Rebind context
See documentation for [`with`](https://gohugo.io/functions/go-template/with/)
, [`else`](https://gohugo.io/functions/go-template/else/)
, and [`end`](https://gohugo.io/functions/go-template/end/)
.
{{ $var := "foo" }}
{{ with $var }}
{{ . }} → foo
{{ else }}
{{ print "var is falsy" }}
{{ end }}
To test multiple conditions:
{{ $v1 := 0 }}
{{ $v2 := 42 }}
{{ with $v1 }}
{{ . }}
{{ else with $v2 }}
{{ . }} → 42
{{ else }}
{{ print "v1 and v2 are falsy" }}
{{ end }}
### Access site parameters
See documentation for the [`Params`](https://gohugo.io/methods/site/params/)
method on a `Site` object.
With this project configuration:
baseURL: https://example.org
params:
author:
email: jsmith@example.org
name: John Smith
copyright-year: '2023'
layouts:
rfc_1123: Mon, 02 Jan 2006 15:04:05 MST
rfc_3339: '2006-01-02T15:04:05-07:00'
subtitle: The Best Widgets on Earth
title: ABC Widgets
baseURL = 'https://example.org'
title = 'ABC Widgets'
[params]
copyright-year = '2023'
subtitle = 'The Best Widgets on Earth'
[params.author]
email = 'jsmith@example.org'
name = 'John Smith'
[params.layouts]
rfc_1123 = 'Mon, 02 Jan 2006 15:04:05 MST'
rfc_3339 = '2006-01-02T15:04:05-07:00'
{
"baseURL": "https://example.org",
"params": {
"author": {
"email": "jsmith@example.org",
"name": "John Smith"
},
"copyright-year": "2023",
"layouts": {
"rfc_1123": "Mon, 02 Jan 2006 15:04:05 MST",
"rfc_3339": "2006-01-02T15:04:05-07:00"
},
"subtitle": "The Best Widgets on Earth"
},
"title": "ABC Widgets"
}
Access the custom site parameters by chaining the identifiers:
{{ .Site.Params.subtitle }} → The Best Widgets on Earth
{{ .Site.Params.author.name }} → John Smith
{{ $layout := .Site.Params.layouts.rfc_1123 }}
{{ .Site.Lastmod.Format $layout }} → Tue, 17 Oct 2023 13:21:02 PDT
### Access page parameters
See documentation for the [`Params`](https://gohugo.io/methods/page/params/)
method on a `Page` object.
By way of example, consider this front matter:
---
date: 2023-10-17T15:11:37-07:00
params:
author:
email: jsmith@example.org
name: John Smith
display_related: true
key-with-hyphens: must use index function
title: Annual conference
---
+++
date = 2023-10-17T15:11:37-07:00
title = 'Annual conference'
[params]
display_related = true
key-with-hyphens = 'must use index function'
[params.author]
email = 'jsmith@example.org'
name = 'John Smith'
+++
{
"date": "2023-10-17T15:11:37-07:00",
"params": {
"author": {
"email": "jsmith@example.org",
"name": "John Smith"
},
"display_related": true,
"key-with-hyphens": "must use index function"
},
"title": "Annual conference"
}
The `title` and `date` fields are standard [front matter fields](https://gohugo.io/content-management/front-matter/#fields)
, while the other fields are user-defined.
Access the custom fields by [chaining](https://gohugo.io/quick-reference/glossary/#chain)
the [identifiers](https://gohugo.io/quick-reference/glossary/#identifier)
when needed:
{{ .Params.display_related }} → true
{{ .Params.author.email }} → jsmith@example.org
{{ .Params.author.name }} → John Smith
In the template example above, each of the keys is a valid identifier. For example, none of the keys contains a hyphen. To access a key that is not a valid identifier, use the [`index`](https://gohugo.io/functions/collections/indexfunction/)
function:
{{ index .Params "key-with-hyphens" }} → must use index function
* * *
Last updated: February 27, 2026 : [content: Miscellaneous udpates for v0.157.0 (35da1aa3c)](https://github.com/gohugoio/hugoDocs/commit/35da1aa3c2fe3b54bdb57df1a308533844af9df5)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/introduction.md)
---
# Cast functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### cast.ToFloat\
\
cast.ToFloat INPUT\
\
Converts a value to a decimal floating-point number (base 10).](https://gohugo.io/functions/cast/tofloat/)
[### cast.ToInt\
\
cast.ToInt INPUT\
\
Converts a value to a decimal integer (base 10).](https://gohugo.io/functions/cast/toint/)
[### cast.ToString\
\
cast.ToString INPUT\
\
Converts a value to a string.](https://gohugo.io/functions/cast/tostring/)
---
# ByName
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given menu with its entries sorted by name.
Syntax
MENU.ByName
Returns
navigation.Menu
The `Sort` method returns the given menu with its entries sorted by `name`.
Consider this menu definition:
menus:
main:
- name: Services
pageRef: /services
weight: 10
- name: About
pageRef: /about
weight: 20
- name: Contact
pageRef: /contact
weight: 30
[menus]
[[menus.main]]
name = 'Services'
pageRef = '/services'
weight = 10
[[menus.main]]
name = 'About'
pageRef = '/about'
weight = 20
[[menus.main]]
name = 'Contact'
pageRef = '/contact'
weight = 30
{
"menus": {
"main": [\
{\
"name": "Services",\
"pageRef": "/services",\
"weight": 10\
},\
{\
"name": "About",\
"pageRef": "/about",\
"weight": 20\
},\
{\
"name": "Contact",\
"pageRef": "/contact",\
"weight": 30\
}\
]
}
}
To sort the entries by `name`:
You can also sort menu entries using the [`sort`](https://gohugo.io/functions/collections/sort/)
function. For example, to sort by `name` in descending order:
When using the sort function with menu entries, specify any of the following keys: `Identifier`, `Name`, `Parent`, `Post`, `Pre`, `Title`, `URL`, or `Weight`.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/menu/ByName.md)
---
# cast.ToInt
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Converts a value to a decimal integer (base 10).
Syntax
cast.ToInt INPUT
Returns
int
Alias
int
With a decimal (base 10) input:
{{ int 11 }} → 11 (int)
{{ int "11" }} → 11 (int)
{{ int 11.1 }} → 11 (int)
{{ int 11.9 }} → 11 (int)
With a binary (base 2) input:
{{ int 0b11 }} → 3 (int)
{{ int "0b11" }} → 3 (int)
With an octal (base 8) input (use either notation):
{{ int 011 }} → 9 (int)
{{ int "011" }} → 9 (int)
{{ int 0o11 }} → 9 (int)
{{ int "0o11" }} → 9 (int)
With a hexadecimal (base 16) input:
{{ int 0x11 }} → 17 (int)
{{ int "0x11" }} → 17 (int)
Values with a leading zero are octal (base 8). When casting a string representation of a decimal (base 10) number, remove leading zeros:
`{{ strings.TrimLeft "0" "0011" | int }} → 11`
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/cast/ToInt.md)
---
# cast.ToFloat
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Converts a value to a decimal floating-point number (base 10).
Syntax
cast.ToFloat INPUT
Returns
float64
Alias
float
With a decimal (base 10) input:
{{ float 11 }} → 11 (float64)
{{ float "11" }} → 11 (float64)
{{ float 11.1 }} → 11.1 (float64)
{{ float "11.1" }} → 11.1 (float64)
{{ float 11.9 }} → 11.9 (float64)
{{ float "11.9" }} → 11.9 (float64)
With a binary (base 2) input:
{{ float 0b11 }} → 3 (float64)
With an octal (base 8) input (use either notation):
{{ float 011 }} → 9 (float64)
{{ float "011" }} → 11 (float64)
{{ float 0o11 }} → 9 (float64)
With a hexadecimal (base 16) input:
{{ float 0x11 }} → 17 (float64)
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/cast/ToFloat.md)
---
# cast.ToString
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Converts a value to a string.
Syntax
cast.ToString INPUT
Returns
string
Alias
string
With a decimal (base 10) input:
{{ string 11 }} → 11 (string)
{{ string "11" }} → 11 (string)
{{ string 11.1 }} → 11.1 (string)
{{ string "11.1" }} → 11.1 (string)
{{ string 11.9 }} → 11.9 (string)
{{ string "11.9" }} → 11.9 (string)
With a binary (base 2) input:
{{ string 0b11 }} → 3 (string)
{{ string "0b11" }} → 0b11 (string)
With an octal (base 8) input (use either notation):
{{ string 011 }} → 9 (string)
{{ string "011" }} → 011 (string)
{{ string 0o11 }} → 9 (string)
{{ string "0o11" }} → 0o11 (string)
With a hexadecimal (base 16) input:
{{ string 0x11 }} → 17 (string)
{{ string "0x11" }} → 0x11 (string)
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/cast/ToString.md)
---
# Blockquote render hooks
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Create blockquote render hook templates to override the rendering of Markdown blockquotes to HTML.
[New in v0.132.0](https://github.com/gohugoio/hugo/releases/tag/v0.132.0)
Context
-------
Blockquote _render hook_ templates receive the following [context](https://gohugo.io/quick-reference/glossary/#context)
:
AlertType
(`string`) Applicable when [`Type`](https://gohugo.io/render-hooks/blockquotes/#type)
is `alert`, this is the alert type converted to lowercase. See the [alerts](https://gohugo.io/render-hooks/blockquotes/#alerts)
section below.
AlertTitle
[New in v0.134.0](https://github.com/gohugoio/hugo/releases/tag/v0.134.0)
(`template.HTML`) Applicable when [`Type`](https://gohugo.io/render-hooks/blockquotes/#type)
is `alert`, this is the alert title. See the [alerts](https://gohugo.io/render-hooks/blockquotes/#alerts)
section below.
AlertSign
[New in v0.134.0](https://github.com/gohugoio/hugo/releases/tag/v0.134.0)
(`string`) Applicable when [`Type`](https://gohugo.io/render-hooks/blockquotes/#type)
is `alert`, this is the alert sign. Typically used to indicate whether an alert is graphically foldable, this is one of `+`, `-`, or an empty string. See the [alerts](https://gohugo.io/render-hooks/blockquotes/#alerts)
section below.
Attributes
(`map`) The [Markdown attributes](https://gohugo.io/content-management/markdown-attributes/)
, available if you configure your site as follows:
markup:
goldmark:
parser:
attribute:
block: true
[markup]
[markup.goldmark]
[markup.goldmark.parser]
[markup.goldmark.parser.attribute]
block = true
{
"markup": {
"goldmark": {
"parser": {
"attribute": {
"block": true
}
}
}
}
}
Ordinal
(`int`) The zero-based ordinal of the blockquote on the page.
Page
(`page`) A reference to the current page.
PageInner
(`page`) A reference to a page nested via the [`RenderShortcodes`](https://gohugo.io/methods/page/rendershortcodes/)
method. [See details](https://gohugo.io/render-hooks/blockquotes/#pageinner-details)
.
Position
(`string`) The position of the blockquote within the page content.
Text
(`template.HTML`) The blockquote text, excluding the first line if [`Type`](https://gohugo.io/render-hooks/blockquotes/#type)
is `alert`. See the [alerts](https://gohugo.io/render-hooks/blockquotes/#alerts)
section below.
Type
(`string`) The blockquote type. Returns `alert` if the blockquote has an alert designator, else `regular`. See the [alerts](https://gohugo.io/render-hooks/blockquotes/#alerts)
section below.
Examples
--------
In its default configuration, Hugo renders Markdown blockquotes according to the [CommonMark specification](https://spec.commonmark.org/current/)
. To create a render hook that does the same thing:
layouts/\_markup/render-blockquote.html
{{ .Text }}
To render a blockquote as an HTML `figure` element with an optional citation and caption:
layouts/\_markup/render-blockquote.html
{{ .Text }}
{{ with .Attributes.caption }}
{{ . | safeHTML }}
{{ end }}
Then in your markdown:
> Some text
{cite="https://gohugo.io" caption="Some caption"}
Alerts
------
Also known as _callouts_ or _admonitions_, alerts are blockquotes used to emphasize critical information.
### Basic syntax
With the basic Markdown syntax, the first line of each alert is an alert designator consisting of an exclamation point followed by the alert type, wrapped within brackets. For example:
content/example.md
> [!NOTE]
> Useful information that users should know, even when skimming content.
> [!TIP]
> Helpful advice for doing things better or more easily.
> [!IMPORTANT]
> Key information users need to know to achieve their goal.
> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.
> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
The basic syntax is compatible with [GitHub](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts)
, [Obsidian](https://help.obsidian.md/Editing+and+formatting/Callouts)
, and [Typora](https://support.typora.io/Markdown-Reference/#callouts--github-style-alerts)
.
### Extended syntax
With the extended Markdown syntax, you may optionally include an alert sign and/or an alert title. The alert sign is one of `+` or `-`, typically used to indicate whether an alert is graphically foldable. For example:
content/example.md
> [!WARNING]+ Radiation hazard
> Do not approach or handle without protective gear.
The extended syntax is compatible with [Obsidian](https://help.obsidian.md/Editing+and+formatting/Callouts)
.
The extended syntax is not compatible with GitHub or Typora. If you include an alert sign or an alert title, these applications render the Markdown as a blockquote.
### Example
This blockquote render hook renders a multilingual alert if an alert designator is present, otherwise it renders a blockquote according to the CommonMark specification.
layouts/\_markup/render-blockquote.html
{{ $emojis := dict
"caution" ":exclamation:"
"important" ":information_source:"
"note" ":information_source:"
"tip" ":bulb:"
"warning" ":information_source:"
}}
{{ if eq .Type "alert" }}
{{ transform.Emojify (index $emojis .AlertType) }}
{{ with .AlertTitle }}
{{ . }}
{{ else }}
{{ or (i18n .AlertType) (title .AlertType) }}
{{ end }}
{{ .Text }}
{{ else }}
{{ .Text }}
{{ end }}
To override the label, create these entries in your i18n files:
caution: Caution
important: Important
note: Note
tip: Tip
warning: Warning
caution = 'Caution'
important = 'Important'
note = 'Note'
tip = 'Tip'
warning = 'Warning'
{
"caution": "Caution",
"important": "Important",
"note": "Note",
"tip": "Tip",
"warning": "Warning"
}
Although you can use one template with conditional logic as shown above, you can also create separate templates for each [`Type`](https://gohugo.io/render-hooks/blockquotes/#type)
of blockquote:
layouts/
└── _markup/
├── render-blockquote-alert.html
└── render-blockquote-regular.html
PageInner details
-----------------
The primary use case for `PageInner` is to resolve links and [page resources](https://gohugo.io/quick-reference/glossary/#page-resource)
relative to an included `Page`. For example, create an “include” shortcode to compose a page from multiple content files, while preserving a global context for footnotes and the table of contents:
layouts/\_shortcodes/include.html
{{ with .Get 0 }}
{{ with $.Page.GetPage . }}
{{- .RenderShortcodes }}
{{ else }}
{{ errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires a positional parameter indicating the logical path of the file to include. See %s" .Name .Position }}
{{ end }}
Then call the shortcode in your Markdown:
content/posts/post-1.md
{{% include "/posts/post-2" %}}
Any render hook triggered while rendering `/posts/post-2` will get:
* `/posts/post-1` when calling `Page`
* `/posts/post-2` when calling `PageInner`
`PageInner` falls back to the value of `Page` if not relevant, and always returns a value.
The `PageInner` method is only relevant for shortcodes that invoke the [`RenderShortcodes`](https://gohugo.io/methods/page/rendershortcodes/)
method, and you must call the shortcode using [Markdown notation](https://gohugo.io/content-management/shortcodes/#notation)
.
As a practical example, Hugo’s embedded link and image render hooks use the `PageInner` method to resolve markdown link and image destinations. See the source code for each:
* [Embedded link render hook](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-link.html)
* [Embedded image render hook](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-image.html)
* * *
Last updated: August 23, 2025 : [Merge commit 'bfa74537929f409fca841540b971125b7678963a' (6c911d1e5)](https://github.com/gohugoio/hugoDocs/commit/6c911d1e52fb9c8065c079820327f4b0e37529d4)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/render-hooks/blockquotes.md)
---
# Embedded partial templates
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hugo provides embedded partial templates for common use cases.
We did a complete overhaul of Hugo’s template system in v0.146.0. We’re working on getting all of the relevant documentation up to date, but until then, see [this page](https://gohugo.io/templates/new-templatesystem-overview/)
.
Disqus
------
To override Hugo’s embedded Disqus template, copy the [source code](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/disqus.html)
to a file with the same name in the `layouts/_partials` directory, then call it from your templates using the [`partial`](https://gohugo.io/functions/partials/include/)
function:
`{{ partial "disqus.html" . }}`
Hugo includes an embedded template for [Disqus](https://disqus.com/)
, a popular commenting system for both static and dynamic websites. To effectively use Disqus, secure a Disqus “shortname” by [signing up](https://disqus.com/profile/signup/)
for the free service.
To include the embedded template:
{{ partial "disqus.html" . }}
### Configuration
To use Hugo’s Disqus template, first set up a single configuration value:
services:
disqus:
shortname: your-disqus-shortname
[services]
[services.disqus]
shortname = 'your-disqus-shortname'
{
"services": {
"disqus": {
"shortname": "your-disqus-shortname"
}
}
}
Hugo’s Disqus template accesses this value with:
{{ .Site.Config.Services.Disqus.Shortname }}
You can also set the following in the front matter for a given piece of content:
* `disqus_identifier`
* `disqus_title`
* `disqus_url`
### Privacy
Adjust the relevant privacy settings in your project configuration.
privacy:
disqus:
disable: false
[privacy]
[privacy.disqus]
disable = false
{
"privacy": {
"disqus": {
"disable": false
}
}
}
disable
(`bool`) Whether to disable the template. Default is `false`.
Google Analytics
----------------
To override Hugo’s embedded Google Analytics template, copy the [source code](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/google_analytics.html)
to a file with the same name in the `layouts/_partials` directory, then call it from your templates using the [`partial`](https://gohugo.io/functions/partials/include/)
function:
`{{ partial "google_analytics.html" . }}`
Hugo includes an embedded template supporting [Google Analytics 4](https://support.google.com/analytics/answer/10089681)
.
To include the embedded template:
{{ partial "google_analytics.html" . }}
### Configuration
Provide your tracking ID in your configuration file:
services:
googleAnalytics:
id: G-MEASUREMENT_ID
[services]
[services.googleAnalytics]
id = 'G-MEASUREMENT_ID'
{
"services": {
"googleAnalytics": {
"id": "G-MEASUREMENT_ID"
}
}
}
To use this value in your own template, access the configured ID with `{{ site.Config.Services.GoogleAnalytics.ID }}`.
### Privacy
Adjust the relevant privacy settings in your project configuration.
privacy:
googleAnalytics:
disable: false
respectDoNotTrack: true
[privacy]
[privacy.googleAnalytics]
disable = false
respectDoNotTrack = true
{
"privacy": {
"googleAnalytics": {
"disable": false,
"respectDoNotTrack": true
}
}
}
disable
(`bool`) Whether to disable the template. Default is `false`.
respectDoNotTrack
(`bool`) Whether to respect the browser’s “do not track” setting. Default is `true`.
Open Graph
----------
To override Hugo’s embedded Open Graph template, copy the [source code](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/opengraph.html)
to a file with the same name in the `layouts/_partials` directory, then call it from your templates using the [`partial`](https://gohugo.io/functions/partials/include/)
function:
`{{ partial "opengraph.html" . }}`
Hugo includes an embedded template for the [Open Graph protocol](https://ogp.me/)
, metadata that enables a page to become a rich object in a social graph. This format is used for Facebook and some other sites.
To include the embedded template:
{{ partial "opengraph.html" . }}
### Configuration
Hugo’s Open Graph template is configured using a mix of configuration settings and [front matter](https://gohugo.io/content-management/front-matter/)
on individual pages.
params:
description: Text about my cool site
images:
- site-feature-image.jpg
social:
facebook_admin: jsmith
title: My cool site
taxonomies:
series: series
[params]
description = 'Text about my cool site'
images = ['site-feature-image.jpg']
title = 'My cool site'
[params.social]
facebook_admin = 'jsmith'
[taxonomies]
series = 'series'
{
"params": {
"description": "Text about my cool site",
"images": [\
"site-feature-image.jpg"\
],
"social": {
"facebook_admin": "jsmith"
},
"title": "My cool site"
},
"taxonomies": {
"series": "series"
}
}
---
audio: []
date: 2024-03-08T08:18:11-08:00
description: Text about this post
images:
- post-cover.png
series: []
tags: []
title: Post title
videos: []
---
+++
audio = []
date = 2024-03-08T08:18:11-08:00
description = 'Text about this post'
images = ['post-cover.png']
series = []
tags = []
title = 'Post title'
videos = []
+++
{
"audio": [],
"date": "2024-03-08T08:18:11-08:00",
"description": "Text about this post",
"images": [\
"post-cover.png"\
],
"series": [],
"tags": [],
"title": "Post title",
"videos": []
}
Hugo uses the page title and description for the title and description metadata. The first 6 URLs from the `images` array are used for image metadata. If [page bundles](https://gohugo.io/content-management/page-bundles/)
are used and the `images` array is empty or undefined, images with file names matching `*feature*`, `*cover*`, or `*thumbnail*` are used for image metadata.
Various optional metadata can also be set:
* Date, published date, and last modified data are used to set the published time metadata if specified.
* `audio` and `videos` are URL arrays like `images` for the audio and video metadata tags, respectively.
* The first 6 `tags` on the page are used for the tags metadata.
* The `series` taxonomy is used to specify related “see also” pages by placing them in the same series.
If using YouTube this will produce a og:video tag like ``. Use the `https://youtu.be/` format with YouTube videos (example: `https://youtu.be/qtIqKaDlqXo`).
Pagination
----------
See [details](https://gohugo.io/templates/pagination/)
.
Schema
------
To override Hugo’s embedded Schema template, copy the [source code](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/schema.html)
to a file with the same name in the `layouts/_partials` directory, then call it from your templates using the [`partial`](https://gohugo.io/functions/partials/include/)
function:
`{{ partial "schema.html" . }}`
Hugo includes an embedded template to render [microdata](https://html.spec.whatwg.org/multipage/microdata.html#microdata)
`meta` elements within the `head` element of your templates.
To include the embedded template:
{{ partial "schema.html" . }}
X (Twitter) Cards
-----------------
To override Hugo’s embedded Twitter Cards template, copy the [source code](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/twitter_cards.html)
to a file with the same name in the `layouts/_partials` directory, then call it from your templates using the [`partial`](https://gohugo.io/functions/partials/include/)
function:
`{{ partial "twitter_cards.html" . }}`
Hugo includes an embedded template for [X (Twitter) Cards](https://developer.x.com/en/docs/twitter-for-websites/cards/overview/abouts-cards)
, metadata used to attach rich media to Tweets linking to your site.
To include the embedded template:
{{ partial "twitter_cards.html" . }}
### Configuration
Hugo’s X (Twitter) Card template is configured using a mix of configuration settings and [front-matter](https://gohugo.io/content-management/front-matter/)
values on individual pages.
params:
description: Text about my cool site
images:
- site-feature-image.jpg
[params]
description = 'Text about my cool site'
images = ['site-feature-image.jpg']
{
"params": {
"description": "Text about my cool site",
"images": [\
"site-feature-image.jpg"\
]
}
}
---
description: Text about this post
images:
- post-cover.png
title: Post title
---
+++
description = 'Text about this post'
images = ['post-cover.png']
title = 'Post title'
+++
{
"description": "Text about this post",
"images": [\
"post-cover.png"\
],
"title": "Post title"
}
If [page bundles](https://gohugo.io/content-management/page-bundles/)
are used and the `images` array is empty or undefined, images with file names matching `*feature*`, `*cover*`, or `*thumbnail*` are used for image metadata. If no image resources with those names are found, the images defined in your [project configuration](https://gohugo.io/configuration/)
are used instead. If no images are found at all, then an image-less Twitter `summary` card is used instead of `summary_large_image`.
Hugo uses the page title and description for the card’s title and description fields. The page summary is used if no description is given.
Set the value of `twitter:site` in your project configuration:
params:
social:
twitter: GoHugoIO
[params]
[params.social]
twitter = 'GoHugoIO'
{
"params": {
"social": {
"twitter": "GoHugoIO"
}
}
}
NOTE: The `@` will be added for you
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/embedded.md)
---
# ByCount
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns an ordered taxonomy, sorted by the number of pages associated with each term.
Syntax
TAXONOMY.ByCount
Returns
page.OrderedTaxonomy
The `ByCount` method on a `Taxonomy` object returns an [ordered taxonomy](https://gohugo.io/quick-reference/glossary/#ordered-taxonomy)
, sorted by the number of pages associated with each [term](https://gohugo.io/quick-reference/glossary/#term)
, then sorted alphabetically by term in the event of a tie.
While a `Taxonomy` object is a [map](https://gohugo.io/quick-reference/glossary/#map)
, an ordered taxonomy is a [slice](https://gohugo.io/quick-reference/glossary/#slice)
, where each element is an object that contains the term and a slice of its [weighted pages](https://gohugo.io/quick-reference/glossary/#weighted-page)
.
Before we can use a `Taxonomy` method, we need to capture a `Taxonomy` object.
Capture a Taxonomy object
-------------------------
Consider this project configuration:
taxonomies:
author: authors
genre: genres
[taxonomies]
author = 'authors'
genre = 'genres'
{
"taxonomies": {
"author": "authors",
"genre": "genres"
}
}
And this content structure:
content/
├── books/
│ ├── and-then-there-were-none.md --> genres: suspense
│ ├── death-on-the-nile.md --> genres: suspense
│ └── jamaica-inn.md --> genres: suspense, romance
│ └── pride-and-prejudice.md --> genres: romance
└── _index.md
To capture the “genres” `Taxonomy` object from within any template, use the [`Taxonomies`](https://gohugo.io/methods/site/taxonomies/)
method on a `Site` object.
{{ $taxonomyObject := .Site.Taxonomies.genres }}
To capture the “genres” `Taxonomy` object when rendering its page with a _taxonomy_ template, use the [`Terms`](https://gohugo.io/methods/page/data/#in-a-taxonomy-template)
method on the page’s [`Data`](https://gohugo.io/methods/page/data/)
object:
layouts/taxonomy.html
{{ $taxonomyObject := .Data.Terms }}
To inspect the data structure:
{{ debug.Dump $taxonomyObject }}
Although the [`Alphabetical`](https://gohugo.io/methods/taxonomy/alphabetical/)
and [`ByCount`](https://gohugo.io/methods/taxonomy/bycount/)
methods provide a better data structure for ranging through the taxonomy, you can render the weighted pages by term directly from the `Taxonomy` object:
{{ range $term, $weightedPages := $taxonomyObject }}
{{ end }}
In the example above, the first anchor element is a link to the term page.
Get the ordered taxonomy
------------------------
Now that we have captured the “genres” Taxonomy object, let’s get the ordered taxonomy sorted by the number of pages associated with each term:
{{ $taxonomyObject.ByCount }}
To reverse the sort order:
{{ $taxonomyObject.ByCount.Reverse }}
To inspect the data structure:
{{ debug.Dump $taxonomyObject.ByCount }}
An ordered taxonomy is a slice, where each element is an object that contains the term and a slice of its weighted pages.
Each element of the slice provides these methods:
Count
(`int`) Returns the number of pages to which the term is assigned.
Page
(`page.Page`) Returns the term’s `Page` object, useful for linking to the term page.
Pages
(`page.Pages`) Returns a `Pages` object containing the `Page` objects to which the term is assigned, sorted by [taxonomic weight](https://gohugo.io/quick-reference/glossary/#taxonomic-weight)
. To sort or group, use any of the [methods](https://gohugo.io/methods/pages/)
available to the `Pages` object. For example, sort by the last modification date.
Term
(`string`) Returns the term name.
WeightedPages
(`page.WeightedPages`) Returns a slice of weighted pages to which the term is assigned, sorted by taxonomic weight. The `Pages` method above is more flexible, allowing you to sort and group.
Example
-------
With this template:
{{ range $taxonomyObject.ByCount }}
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/taxonomy/ByCount.md)
---
# ByWeight
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given menu with its entries sorted by weight, then by name, then by identifier.
Syntax
MENU.ByWeight
Returns
navigation.Menu
The `ByWeight` method returns the given menu with its entries sorted by [`weight`](https://gohugo.io/quick-reference/glossary/#weight)
, then by `name`, then by `identifier`. This is the default sort order.
Consider this menu definition:
menus:
main:
- identifier: about
name: About
pageRef: /about
weight: 20
- identifier: services
name: Services
pageRef: /services
weight: 10
- identifier: contact
name: Contact
pageRef: /contact
weight: 30
[menus]
[[menus.main]]
identifier = 'about'
name = 'About'
pageRef = '/about'
weight = 20
[[menus.main]]
identifier = 'services'
name = 'Services'
pageRef = '/services'
weight = 10
[[menus.main]]
identifier = 'contact'
name = 'Contact'
pageRef = '/contact'
weight = 30
{
"menus": {
"main": [\
{\
"identifier": "about",\
"name": "About",\
"pageRef": "/about",\
"weight": 20\
},\
{\
"identifier": "services",\
"name": "Services",\
"pageRef": "/services",\
"weight": 10\
},\
{\
"identifier": "contact",\
"name": "Contact",\
"pageRef": "/contact",\
"weight": 30\
}\
]
}
}
To sort the entries by `weight`, then by `name`, then by `identifier`:
In the menu definition above, note that the `identifier` property is only required when two or more menu entries have the same name, or when localizing the name using translation tables.
You can also sort menu entries using the [`sort`](https://gohugo.io/functions/collections/sort/)
function. For example, to sort by `weight` in descending order:
When using the sort function with menu entries, specify any of the following keys: `Identifier`, `Name`, `Parent`, `Post`, `Pre`, `Title`, `URL`, or `Weight`.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/menu/ByWeight.md)
---
# and
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the first falsy argument. If all arguments are truthy, returns the last argument.
Syntax
and VALUE...
Returns
any
The falsy values are `false`, `0`, any `nil` pointer or interface value, any array, slice, map, or string of length zero, and zero `time.Time` values.
Everything else is truthy.
The `and` function evaluates the arguments from left to right, and returns when the result is determined.
{{ and 1 0 "" }} → 0 (int)
{{ and 1 false 0 }} → false (bool)
{{ and 1 2 3 }} → 3 (int)
{{ and "a" "b" "c" }} → c (string)
{{ and "a" 1 true }} → true (bool)
{{ and false (math.Div 1 0) }} → false (bool)
See Go’s [`text/template`](https://pkg.go.dev/text/template)
documentation for more information.
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/go-template/and.md)
---
# break
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Used with the range statement, stops the innermost iteration and bypasses all remaining iterations.
Syntax
break
This template code:
{{ $s := slice "foo" "bar" "baz" }}
{{ range $s }}
{{ if eq . "bar" }}
{{ break }}
{{ end }}
{{ . }}
{{ end }}
Is rendered to:
foo
See Go’s [`text/template`](https://pkg.go.dev/text/template)
documentation for more information.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/go-template/break.md)
---
# block
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Defines a template and executes it in place.
Syntax
block NAME CONTEXT
A block is shorthand for defining a template:
{{ define "name" }} T1 {{ end }}
and then executing it in place:
{{ template "name" pipeline }}
The typical use is to define a set of root templates that are then customized by redefining the block templates within.
layouts/baseof.html
{{ block "main" . }}
{{ print "default value if 'main' template is empty" }}
{{ end }}
layouts/page.html
{{ define "main" }}
{{ end }}
{{ end }}
See Go’s [`text/template`](https://pkg.go.dev/text/template)
documentation for more information.
* * *
Last updated: August 23, 2025 : [Merge commit 'bfa74537929f409fca841540b971125b7678963a' (6c911d1e5)](https://github.com/gohugoio/hugoDocs/commit/6c911d1e52fb9c8065c079820327f4b0e37529d4)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/go-template/block.md)
---
# Add
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given time plus the given duration.
Syntax
TIME.Add DURATION
Returns
time.Time
{{ $t := time.AsTime "2023-01-27T23:44:58-08:00" }}
{{ $d1 = time.ParseDuration "3h20m10s" }}
{{ $d2 = time.ParseDuration "-3h20m10s" }}
{{ $t.Add $d1 }} → 2023-01-28 03:05:08 -0800 PST
{{ $t.Add $d2 }} → 2023-01-27 20:24:48 -0800 PST
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/time/Add.md)
---
# Code block render hooks
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Create code block render hook templates to override the rendering of Markdown code blocks to HTML.
Markdown
--------
This Markdown example contains a fenced code block:
content/example.md
```sh {class="my-class" id="my-codeblock" lineNos=inline tabWidth=2}
declare a=1
echo "$a"
exit
```
A fenced code block consists of:
* A leading [code fence](https://spec.commonmark.org/current/#code-fence)
* An optional [info string](https://spec.commonmark.org/current/#info-string)
* A code sample
* A trailing code fence
In the previous example, the info string contains:
* The language of the code sample (the first word)
* An optional space-delimited or comma-delimited list of attributes (everything within braces)
The attributes in the info string can be generic attributes or highlighting options.
In the example above, the _generic attributes_ are `class` and `id`. In the absence of special handling within a code block render hook, Hugo adds each generic attribute to the HTML element surrounding the rendered code block. Consistent with its content security model, Hugo removes HTML event attributes such as `onclick` and `onmouseover`. Generic attributes are typically global HTML attributes, but you may include custom attributes as well.
In the example above, the _highlighting options_ are `lineNos` and `tabWidth`. Hugo uses the [Chroma](https://github.com/alecthomas/chroma/)
syntax highlighter to render the code sample. You can control the appearance of the rendered code by specifying one or more [highlighting options](https://gohugo.io/functions/transform/highlight/#options)
.
Although `style` is a global HTML attribute, when used in an info string it is a highlighting option.
Context
-------
Code block _render hook_ templates receive the following [context](https://gohugo.io/quick-reference/glossary/#context)
:
Attributes
(`map`) The generic attributes from the info string.
Inner
(`string`) The content between the leading and trailing code fences, excluding the info string.
Options
(`map`) The highlighting options from the info string. This map is empty if [`Type`](https://gohugo.io/render-hooks/code-blocks/#type)
is an empty string or a code language that is not supported by the Chroma syntax highlighter. However, in this case, the highlighting options are available in the [`Attributes`](https://gohugo.io/render-hooks/code-blocks/#attributes)
map.
Ordinal
(`int`) The zero-based ordinal of the code block on the page.
Page
(`page`) A reference to the current page.
PageInner
(`page`) A reference to a page nested via the [`RenderShortcodes`](https://gohugo.io/methods/page/rendershortcodes/)
method. [See details](https://gohugo.io/render-hooks/code-blocks/#pageinner-details)
.
Position
(`text.Position`) The position of the code block within the page content.
Type
(`string`) The first word of the info string, typically the code language.
Examples
--------
In its default configuration, Hugo renders fenced code blocks by passing the code sample through the Chroma syntax highlighter and wrapping the result. To create a render hook that does the same thing:
layouts/\_markup/render-codeblock.html
{{ $result := transform.HighlightCodeBlock . }}
{{ $result.Wrapped }}
Although you can use one template with conditional logic to control the behavior on a per-language basis, you can also create language-specific templates.
layouts/
└── _markup/
├── render-codeblock-mermaid.html
├── render-codeblock-python.html
└── render-codeblock.html
For example, to create a code block render hook to render [Mermaid](https://mermaid.js.org/)
diagrams:
layouts/\_markup/render-codeblock-mermaid.html
{{ .Inner | htmlEscape | safeHTML }}
{{ .Page.Store.Set "hasMermaid" true }}
Then include this snippet at the _bottom_ of your base template, before the closing `body` tag:
layouts/baseof.html
{{ if .Store.Get "hasMermaid" }}
{{ end }}
See the [diagrams](https://gohugo.io/content-management/diagrams/#mermaid-diagrams)
page for details.
Embedded
--------
Hugo includes an [embedded code block render hook](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-codeblock-goat.html)
to render [GoAT diagrams](https://gohugo.io/content-management/diagrams/#goat-diagrams-ascii)
.
PageInner details
-----------------
The primary use case for `PageInner` is to resolve links and [page resources](https://gohugo.io/quick-reference/glossary/#page-resource)
relative to an included `Page`. For example, create an “include” shortcode to compose a page from multiple content files, while preserving a global context for footnotes and the table of contents:
layouts/\_shortcodes/include.html
{{ with .Get 0 }}
{{ with $.Page.GetPage . }}
{{- .RenderShortcodes }}
{{ else }}
{{ errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires a positional parameter indicating the logical path of the file to include. See %s" .Name .Position }}
{{ end }}
Then call the shortcode in your Markdown:
content/posts/post-1.md
{{% include "/posts/post-2" %}}
Any render hook triggered while rendering `/posts/post-2` will get:
* `/posts/post-1` when calling `Page`
* `/posts/post-2` when calling `PageInner`
`PageInner` falls back to the value of `Page` if not relevant, and always returns a value.
The `PageInner` method is only relevant for shortcodes that invoke the [`RenderShortcodes`](https://gohugo.io/methods/page/rendershortcodes/)
method, and you must call the shortcode using [Markdown notation](https://gohugo.io/content-management/shortcodes/#notation)
.
As a practical example, Hugo’s embedded link and image render hooks use the `PageInner` method to resolve markdown link and image destinations. See the source code for each:
* [Embedded link render hook](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-link.html)
* [Embedded image render hook](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-image.html)
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/render-hooks/code-blocks.md)
---
# After
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports whether TIME1 is after TIME2.
Syntax
TIME1.After TIME2
Returns
bool
{{ $t1 := time.AsTime "2023-01-01T17:00:00-08:00" }}
{{ $t2 := time.AsTime "2010-01-01T17:00:00-08:00" }}
{{ $t1.After $t2 }} → true
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/time/After.md)
---
# AddDate
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the time corresponding to adding the given number of years, months, and days to the given time.Time value.
Syntax
TIME.AddDate YEARS MONTHS DAYS
Returns
time.Time
{{ $d := "2022-01-01" | time.AsTime }}
{{ $d.AddDate 0 0 1 | time.Format "2006-01-02" }} → 2022-01-02
{{ $d.AddDate 0 1 1 | time.Format "2006-01-02" }} → 2022-02-02
{{ $d.AddDate 1 1 1 | time.Format "2006-01-02" }} → 2023-02-02
{{ $d.AddDate -1 -1 -1 | time.Format "2006-01-02" }} → 2020-11-30
When adding months or years, Hugo normalizes the final `time.Time` value if the resulting day does not exist. For example, adding one month to 31 January produces 2 March or 3 March, depending on the year.
See [this explanation](https://github.com/golang/go/issues/31145#issuecomment-479067967)
from the Go team.
{{ $d := "2023-01-31" | time.AsTime }}
{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} → 2023-03-03
{{ $d := "2024-01-31" | time.AsTime }}
{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} → 2024-03-02
{{ $d := "2024-02-29" | time.AsTime }}
{{ $d.AddDate 1 0 0 | time.Format "2006-01-02" }} → 2025-03-01
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/time/AddDate.md)
---
# AllPages
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a collection of all pages in all languages.
Syntax
SITE.AllPages
Returns
page.Pages
Deprecated in [v0.156.0](https://github.com/gohugoio/hugo/releases/tag/v0.156.0)
See [details](https://discourse.gohugo.io/t/56732)
.
* * *
Last updated: March 2, 2026 : [content: Clean up content for deprecated features (850dc5b2b)](https://github.com/gohugoio/hugoDocs/commit/850dc5b2b26b7136504b24a46d6abede248c0fed)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/site/AllPages.md)
---
# All settings
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

The complete list of Hugo configuration settings.
Settings
--------
archetypeDir
(`string`) The designated directory for [archetypes](https://gohugo.io/quick-reference/glossary/#archetype)
. Default is `archetypes`. For a more flexible approach to configuring this directory, consult the section on [module mounts](https://gohugo.io/configuration/module/#mounts)
.
assetDir
(`string`) The designated directory for [global resources](https://gohugo.io/quick-reference/glossary/#global-resource)
. Default is `assets`. For a more flexible approach to configuring this directory, consult the section on [module mounts](https://gohugo.io/configuration/module/#mounts)
.
baseURL
(`string`) The absolute URL of your published site including the protocol, host, path, and a trailing slash.
build
See [configure build](https://gohugo.io/configuration/build/)
.
buildDrafts
(`bool`) Whether to include draft content when building a site. Default is `false`.
buildExpired
(`bool`) Whether to include expired content when building a site. Default is `false`.
buildFuture
(`bool`) Whether to include future content when building a site. Default is `false`.
cacheDir
(`string`) The designated cache directory. See [details](https://gohugo.io/configuration/all/#cache-directory)
.
caches
See [configure file caches](https://gohugo.io/configuration/caches/)
.
canonifyURLs
(`bool`) See [details](https://gohugo.io/content-management/urls/#canonical-urls)
before enabling this feature. Default is `false`.
capitalizeListTitles
(`bool`) Whether to capitalize automatic list titles. Applicable to section, taxonomy, and term pages. Use the [`titleCaseStyle`](https://gohugo.io/configuration/all/#titlecasestyle)
setting to configure capitalization rules. Default is `true`.
cascade
See [configure cascade](https://gohugo.io/configuration/cascade/)
.
cleanDestinationDir
(`bool`) Whether to remove files from the [`publishDir`](https://gohugo.io/configuration/all/#publishdir)
that do not exist in the [`staticDir`](https://gohugo.io/configuration/all/#staticdir)
when building the site. This setting will not take effect if the `staticDir` does not exist. Note that `.gitignore` and `.gitattributes` files, along with directories named `.git`, are always preserved in the `publishDir`. Default is `false`.
contentDir
(`string`) The designated directory for content files. Default is `content`. For a more flexible approach to configuring this directory, consult the section on [module mounts](https://gohugo.io/configuration/module/#mounts)
.
copyright
(`string`) The copyright notice for a site, typically displayed in the footer.
dataDir
(`string`) The designated directory for data files. Default is `data`. For a more flexible approach to configuring this directory, consult the section on [module mounts](https://gohugo.io/configuration/module/#mounts)
.
defaultContentLanguage
(`string`) The projects’s [default language](https://gohugo.io/quick-reference/glossary/#default-language)
, conforming to the syntax described in [RFC 5646](https://datatracker.ietf.org/doc/html/rfc5646#section-2.1)
.
defaultContentLanguageInSubdir
(`bool`) Whether to publish the default content language to a subdirectory matching the [`defaultContentLanguage`](https://gohugo.io/configuration/all/#defaultcontentlanguage)
. Default is `false`.
defaultContentRole
[New in v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
(`string`) The project’s [default role](https://gohugo.io/quick-reference/glossary/#default-role)
.
defaultContentRoleInSubdir
[New in v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
(`bool`) Whether to publish the default content [role](https://gohugo.io/quick-reference/glossary/#role)
to a subdirectory matching the [`defaultContentRole`](https://gohugo.io/configuration/all/#defaultcontentrole)
. Default is `false`.
defaultContentVersion
[New in v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
(`string`) The project’s [default version](https://gohugo.io/quick-reference/glossary/#default-version)
.
defaultContentVersionInSubdir
[New in v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
(`bool`) Whether to publish the default content version to a subdirectory matching the [`defaultContentVersion`](https://gohugo.io/configuration/all/#defaultcontentversion)
. Default is `false`.
defaultOutputFormat
(`string`) The default output format for the site. If unspecified, the first available format in the defined order (by weight, then alphabetically) will be used.
deployment
See [configure deployment](https://gohugo.io/configuration/deployment/)
.
disableAliases
(`bool`) Whether to disable the generation of HTML redirect files for each path defined in the [`aliases`](https://gohugo.io/content-management/front-matter/#aliases)
front matter field. When `true`, Hugo will not create physical files for [client-side redirection](https://gohugo.io/content-management/urls/#client-side-redirection)
, but the alias data remains available via the [`Aliases`](https://gohugo.io/methods/page/aliases/)
method on a `Page` object. Default is `false`.
disableDefaultLanguageRedirect
[New in v0.140.0](https://github.com/gohugoio/hugo/releases/tag/v0.140.0)
(`bool`) Whether to disable generation of the alias redirect for the default content language. When [`defaultContentLanguageInSubdir`](https://gohugo.io/configuration/all/#defaultcontentlanguageinsubdir)
is `true`, this setting prevents the root directory from redirecting to the language subdirectory. Conversely, when `defaultContentLanguageInSubdir` is `false`, this setting prevents the language subdirectory from redirecting to the root directory. This is superseded by the more general [`disableDefaultSiteRedirect`](https://gohugo.io/configuration/all/#disabledefaultsiteredirect)
setting. Default is `false`.
disableDefaultSiteRedirect
[New in v0.154.5](https://github.com/gohugoio/hugo/releases/tag/v0.154.5)
(bool) Whether to disable generation of the alias redirect to the [default site](https://gohugo.io/quick-reference/glossary/#default-site)
. When [`defaultContentLanguageInSubdir`](https://gohugo.io/configuration/all/#defaultcontentlanguageinsubdir)
, [`defaultContentRoleInSubdir`](https://gohugo.io/configuration/all/#defaultcontentroleinsubdir)
, or [`defaultContentVersionInSubdir`](https://gohugo.io/configuration/all/#defaultcontentversioninsubdir)
is `true`, this prevents the root directory from redirecting to the default site’s subdirectory. Conversely, when these are `false`, it prevents the subdirectories from redirecting back to the root. Default is `false`.
disableHugoGeneratorInject
(`bool`) Whether to disable injection of a `` tag into the home page. Default is `false`.
disableKinds
(`[]string`) A slice of page [kinds](https://gohugo.io/quick-reference/glossary/#kind)
to disable during the build process, any of `404`, `home`, `page`, `robotstxt`, `rss`, `section`, `sitemap`, `taxonomy`, or `term`.
disableLanguages
(`[]string`) A slice of language keys representing the languages to disable during the build process. Although this is functional, consider using the [`disabled`](https://gohugo.io/configuration/languages/#disabled)
key under each language instead.
disableLiveReload
(`bool`) Whether to disable automatic live reloading of the browser window. Default is `false`.
disablePathToLower
(`bool`) Whether to disable transformation of page URLs to lower case. Default is `false`.
enableEmoji
(`bool`) Whether to allow emoji in Markdown. Default is `false`.
enableGitInfo
(`bool`) Whether to retrieve commit metadata from the Git history of your local project and any [modules](https://gohugo.io/quick-reference/glossary/#module)
. This enables the [`GitInfo`](https://gohugo.io/methods/page/gitinfo/)
method on a `Page` object. With the default front matter configuration, the [`Lastmod`](https://gohugo.io/methods/page/lastmod/)
method on a `Page` object returns the Git author date of the last commit for that file. Default is `false`.
enableMissingTranslationPlaceholders
(`bool`) Whether to show a placeholder instead of the default value or an empty string if a translation is missing. Default is `false`.
enableRobotsTXT
(`bool`) Whether to enable generation of a `robots.txt` file. Default is `false`.
environment
(`string`) The build environment. Default is `production` when running `hugo build` and `development` when running `hugo server`.
frontmatter
See [configure front matter](https://gohugo.io/configuration/front-matter/)
.
hasCJKLanguage
(`bool`) Whether to automatically detect [CJK](https://gohugo.io/quick-reference/glossary/#cjk)
languages in content. Affects the values returned by the [`WordCount`](https://gohugo.io/methods/page/wordcount/)
and [`FuzzyWordCount`](https://gohugo.io/methods/page/fuzzywordcount/)
methods. Default is `false`.
HTTPCache
See [configure HTTP cache](https://gohugo.io/configuration/http-cache/)
.
i18nDir
(`string`) The designated directory for translation tables. Default is `i18n`. For a more flexible approach to configuring this directory, consult the section on [module mounts](https://gohugo.io/configuration/module/#mounts)
.
ignoreCache
(`bool`) Whether to ignore the cache directory. Default is `false`.
ignoreFiles
(`[]string`) A slice of [regular expressions](https://gohugo.io/quick-reference/glossary/#regular-expression)
used to exclude specific files from a build. These expressions are matched against the absolute file path and apply to files within the `content`, `data`, and `i18n` directories. For more advanced file exclusion options, see the section on [module mounts](https://gohugo.io/configuration/module/#mounts)
.
ignoreLogs
(`[]string`) A slice of message identifiers corresponding to warnings and errors you wish to suppress. See [`erroridf`](https://gohugo.io/functions/fmt/erroridf/)
and [`warnidf`](https://gohugo.io/functions/fmt/warnidf/)
.
ignoreVendorPaths
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching the module paths to exclude from the `_vendor` directory.
imaging
See [configure imaging](https://gohugo.io/configuration/imaging/)
.
languageCode
(`string`) The site’s language tag, conforming to the syntax described in [RFC 5646](https://datatracker.ietf.org/doc/html/rfc5646#section-2.1)
. This value does not affect translations or localization. Hugo uses this value to populate:
* The `language` element in the [embedded RSS template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/rss.xml)
* The `lang` attribute of the `html` element in the [embedded alias template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/alias.html)
* The `og:locale` `meta` element in the [embedded Open Graph template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/opengraph.html)
When present in the root of the configuration, this value is ignored if one or more language keys exists. Please specify this value independently for each language key.
languages
See [configure languages](https://gohugo.io/configuration/languages/)
.
layoutDir
(`string`) The designated directory for templates. Default is `layouts`. For a more flexible approach to configuring this directory, consult the section on [module mounts](https://gohugo.io/configuration/module/#mounts)
.
mainSections
(`string` or `[]string`) The main sections of a site. If set, the [`MainSections`](https://gohugo.io/methods/site/mainsections/)
method on the `Site` object returns the given sections, otherwise it returns the section with the most pages.
markup
See [configure markup](https://gohugo.io/configuration/markup/)
.
mediaTypes
See [configure media types](https://gohugo.io/configuration/media-types/)
.
menus
See [configure menus](https://gohugo.io/configuration/menus/)
.
minify
See [configure minify](https://gohugo.io/configuration/minify/)
.
module
See [configure modules](https://gohugo.io/configuration/module/)
.
newContentEditor
(`string`) The editor to use when creating new content.
noBuildLock
(`bool`) Whether to disable creation of the `.hugo_build.lock` file. Default is `false`.
noChmod
(`bool`) Whether to disable synchronization of file permission modes. Default is `false`.
noTimes
(`bool`) Whether to disable synchronization of file modification times. Default is `false`.
outputFormats
See [configure output formats](https://gohugo.io/configuration/output-formats/)
.
outputs
See [configure outputs](https://gohugo.io/configuration/outputs/)
.
page
See [configure page](https://gohugo.io/configuration/page/)
.
pagination
See [configure pagination](https://gohugo.io/configuration/pagination/)
.
panicOnWarning
(`bool`) Whether to panic on the first WARNING. Default is `false`.
params
See [configure params](https://gohugo.io/configuration/params/)
.
permalinks
See [configure permalinks](https://gohugo.io/configuration/permalinks/)
.
pluralizeListTitles
(`bool`) Whether to pluralize automatic list titles. Applicable to section pages. Default is `true`.
printI18nWarnings
(`bool`) Whether to log WARNINGs for each missing translation. Default is `false`.
printPathWarnings
(`bool`) Whether to log WARNINGs when Hugo publishes two or more files to the same path. Default is `false`.
printUnusedTemplates
(`bool`) Whether to log WARNINGs for each unused template. Default is `false`.
privacy
See [configure privacy](https://gohugo.io/configuration/privacy/)
.
publishDir
(`string`) The designated directory for publishing the site. Default is `public`.
refLinksErrorLevel
(`string`) The logging error level to use when the `ref` and `relref` functions, methods, and shortcodes are unable to resolve a reference to a page. Either `ERROR` or `WARNING`. Any `ERROR` will fail the build. Default is `ERROR`.
refLinksNotFoundURL
(`string`) The URL to return when the `ref` and `relref` functions, methods, and shortcodes are unable to resolve a reference to a page.
related
See [configure related content](https://gohugo.io/configuration/related-content/)
.
relativeURLs
(`bool`) See [details](https://gohugo.io/content-management/urls/#relative-urls)
before enabling this feature. Default is `false`.
removePathAccents
(`bool`) Whether to remove [non-spacing marks](https://www.compart.com/en/unicode/category/Mn)
from [composite characters](https://en.wikipedia.org/wiki/Precomposed_character)
in content paths. Default is `false`.
renderSegments
(`[]string`) A slice of [segments](https://gohugo.io/quick-reference/glossary/#segment)
to render. If omitted, all segments are rendered. This option is typically set via a command-line flag, such as `hugo build --renderSegments segment1,segment2`. The provided segment names must correspond to those defined in the [`segments`](https://gohugo.io/configuration/segments/)
configuration.
resourceDir
(`string`) The designated directory for caching output from [asset pipelines](https://gohugo.io/quick-reference/glossary/#asset-pipeline)
. Default is `resources`.
roles
See [configure roles](https://gohugo.io/configuration/roles/)
.
security
See [configure security](https://gohugo.io/configuration/security/)
.
sectionPagesMenu
(`string`) When set, each top-level section will be added to the menu identified by the provided value. See [details](https://gohugo.io/content-management/menus/#define-automatically)
.
segments
See [configure segments](https://gohugo.io/configuration/segments/)
.
server
See [configure server](https://gohugo.io/configuration/server/)
.
services
See [configure services](https://gohugo.io/configuration/services/)
.
sitemap
See [configure sitemap](https://gohugo.io/configuration/sitemap/)
.
staticDir
(`string`) The designated directory for static files. Default is `static`. For a more flexible approach to configuring this directory, consult the section on [module mounts](https://gohugo.io/configuration/module/#mounts)
.
summaryLength
(`int`) Applicable to [automatic summaries](https://gohugo.io/content-management/summaries/#automatic-summary)
, the minimum number of words returned by the [`Summary`](https://gohugo.io/methods/page/summary/)
method on a `Page` object. The `Summary` method will return content truncated at the paragraph boundary closest to the specified `summaryLength`, but at least this minimum number of words. Default is `70`.
taxonomies
See [configure taxonomies](https://gohugo.io/configuration/taxonomies/)
.
templateMetrics
(`bool`) Whether to print template execution metrics to the console. Default is `false`. See [details](https://gohugo.io/troubleshooting/performance/#template-metrics)
.
templateMetricsHints
(`bool`) Whether to print template execution improvement hints to the console. Applicable when `templateMetrics` is `true`. Default is `false`. See [details](https://gohugo.io/troubleshooting/performance/#template-metrics)
.
theme
(`string` or `[]string`) The [theme](https://gohugo.io/quick-reference/glossary/#theme)
to use. Multiple themes can be listed, with precedence given from left to right. See [details](https://gohugo.io/hugo-modules/theme-components/)
.
themesDir
(`string`) The designated directory for themes. Default is `themes`.
timeout
(`string`) The timeout for generating page content, either as a [duration](https://pkg.go.dev/time#Duration)
or in seconds. This timeout is used to prevent infinite recursion during content generation. You may need to increase this value if your pages take a long time to generate, for example, due to extensive image processing or reliance on remote content. Default is `60s`.
timeZone
(`string`) The time zone used to parse dates without time zone offsets, including front matter date fields and values passed to the [`time.AsTime`](https://gohugo.io/functions/time/astime/)
and [`time.Format`](https://gohugo.io/functions/time/format/)
template functions. The list of valid values may be system dependent, but should include `UTC`, `Local`, and any location in the [IANA Time Zone Database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
. For example, `America/Los_Angeles` and `Europe/Oslo` are valid time zones.
title
(`string`) The site title.
titleCaseStyle
(`string`) The capitalization rules to follow when Hugo automatically generates a section title, or when using the [`strings.Title`](https://gohugo.io/functions/strings/title/)
function. One of `ap`, `chicago`, `go`, `firstupper`, or `none`. Default is `ap`. See [details](https://gohugo.io/configuration/all/#title-case-style)
.
uglyurls
See [configure ugly URLs](https://gohugo.io/configuration/ugly-urls/)
.
versions
See [configure versions](https://gohugo.io/configuration/versions/)
.
Cache directory
---------------
Hugo’s file cache directory is configurable via the [`cacheDir`](https://gohugo.io/configuration/all/#cachedir)
configuration option or the `HUGO_CACHEDIR` environment variable. If neither is set, Hugo will use, in order of preference:
1. If running on Netlify: `/opt/build/cache/hugo_cache/`. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other [CI/CD](https://gohugo.io/quick-reference/glossary/#cicd)
platforms, please read their documentation. For a CircleCI example, see [this configuration](https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml)
.
2. In a `hugo_cache` directory below the OS user cache directory as defined by Go’s [os.UserCacheDir](https://pkg.go.dev/os#UserCacheDir)
function. On Unix systems, per the [XDG base directory specification](https://specifications.freedesktop.org/basedir-spec/latest/)
, this is `$XDG_CACHE_HOME` if non-empty, else `$HOME/.cache`. On MacOS, this is `$HOME/Library/Caches`. On Windows, this is`%LocalAppData%`. On Plan 9, this is `$home/lib/cache`.
3. In a `hugo_cache_$USER` directory below the OS temp dir.
To determine the current `cacheDir`:
hugo config | grep cachedir
Title case style
----------------
Hugo’s [`titleCaseStyle`](https://gohugo.io/configuration/all/#titlecasestyle)
setting governs capitalization for automatically generated section titles and the [`strings.Title`](https://gohugo.io/functions/strings/title/)
function. By default, it follows the capitalization rules published in the Associated Press Stylebook. Change this setting to use other capitalization rules.
ap
Use the capitalization rules published in the [Associated Press Stylebook](https://www.apstylebook.com/)
. This is the default.
chicago
Use the capitalization rules published in the [Chicago Manual of Style](https://www.chicagomanualofstyle.org/home.html)
.
go
Capitalize the first letter of every word.
firstupper
Capitalize the first letter of the first word.
none
Disable transformation of automatic section titles, and disable the transformation performed by the `strings.Title` function. This is useful if you would prefer to manually capitalize section titles as needed, and to bypass opinionated theme usage of the `strings.Title` function.
Localized settings
------------------
Some configuration settings, such as menus and custom parameters, can be defined separately for each language. See [configure languages](https://gohugo.io/configuration/languages/)
.
* * *
Last updated: February 27, 2026 : [content: Miscellaneous udpates for v0.157.0 (35da1aa3c)](https://github.com/gohugoio/hugoDocs/commit/35da1aa3c2fe3b54bdb57df1a308533844af9df5)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/configuration/all.md)
---
# Children
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a collection of child menu entries, if any, under the given menu entry.
Syntax
MENUENTRY.Children
Returns
navigation.Menu
Use the `Children` method when rendering a nested menu.
With this project configuration:
menus:
main:
- name: Products
pageRef: /product
weight: 10
- name: Product 1
pageRef: /products/product-1
parent: Products
weight: 1
- name: Product 2
pageRef: /products/product-2
parent: Products
weight: 2
[menus]
[[menus.main]]
name = 'Products'
pageRef = '/product'
weight = 10
[[menus.main]]
name = 'Product 1'
pageRef = '/products/product-1'
parent = 'Products'
weight = 1
[[menus.main]]
name = 'Product 2'
pageRef = '/products/product-2'
parent = 'Products'
weight = 2
{
"menus": {
"main": [\
{\
"name": "Products",\
"pageRef": "/product",\
"weight": 10\
},\
{\
"name": "Product 1",\
"pageRef": "/products/product-1",\
"parent": "Products",\
"weight": 1\
},\
{\
"name": "Product 2",\
"pageRef": "/products/product-2",\
"parent": "Products",\
"weight": 2\
}\
]
}
}
And this template:
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/menu-entry/Children.md)
---
# Compare functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### compare.Conditional\
\
compare.Conditional CONTROL ARG1 ARG2\
\
Returns one of two arguments depending on the value of the control argument.](https://gohugo.io/functions/compare/conditional/)
[### compare.Default\
\
compare.Default DEFAULT INPUT\
\
Returns the second argument if set, else the first argument.](https://gohugo.io/functions/compare/default/)
[### compare.Eq\
\
compare.Eq ARG1 ARG2 \[ARG...\]\
\
Returns the boolean truth of arg1 == arg2 || arg1 == arg3.](https://gohugo.io/functions/compare/eq/)
[### compare.Ge\
\
compare.Ge ARG1 ARG2 \[ARG...\]\
\
Returns the boolean truth of arg1 >= arg2 && arg1 >= arg3.](https://gohugo.io/functions/compare/ge/)
[### compare.Gt\
\
compare.Gt ARG1 ARG2 \[ARG...\]\
\
Returns the boolean truth of arg1 > arg2 && arg1 > arg3.](https://gohugo.io/functions/compare/gt/)
[### compare.Le\
\
compare.Le ARG1 ARG2 \[ARG...\]\
\
Returns the boolean truth of arg1 <= arg2 && arg1 <= arg3.](https://gohugo.io/functions/compare/le/)
[### compare.Lt\
\
compare.Lt ARG1 ARG2 \[ARG...\]\
\
Returns the boolean truth of arg1 < arg2 && arg1 < arg3.](https://gohugo.io/functions/compare/lt/)
[### compare.Ne\
\
compare.Ne ARG1 ARG2 \[ARG...\]\
\
Returns the boolean truth of arg1 != arg2 && arg1 != arg3.](https://gohugo.io/functions/compare/ne/)
---
# Before
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports whether TIME1 is before TIME2.
Syntax
TIME1.Before TIME2
Returns
bool
{{ $t1 := time.AsTime "2023-01-01T17:00:00-08:00" }}
{{ $t2 := time.AsTime "2030-01-01T17:00:00-08:00" }}
{{ $t1.Before $t2 }} → true
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/time/Before.md)
---
# compare.Conditional
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns one of two arguments depending on the value of the control argument.
Syntax
compare.Conditional CONTROL ARG1 ARG2
Returns
any
Alias
cond
If CONTROL is truthy the function returns ARG1, otherwise it returns ARG2.
{{ $qty := 42 }}
{{ cond (le $qty 3) "few" "many" }} → many
Unlike [ternary operators](https://en.wikipedia.org/wiki/Ternary_conditional_operator)
in other languages, the `compare.Conditional` function does not perform [short-circuit evaluation](https://en.wikipedia.org/wiki/Short-circuit_evaluation)
. It evaluates both ARG1 and ARG2 regardless of the CONTROL value.
Due to the absence of short-circuit evaluation, these examples throw an error:
{{ cond true "true" (div 1 0) }}
{{ cond false (div 1 0) "false" }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/compare/Conditional.md)
---
# Shortcode templates
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Create custom shortcodes to simplify and standardize content creation.
We did a complete overhaul of Hugo’s template system in v0.146.0. We’re working on getting all of the relevant documentation up to date, but until then, see [this page](https://gohugo.io/templates/new-templatesystem-overview/)
.
Before creating custom shortcodes, please review the [shortcodes](https://gohugo.io/content-management/shortcodes/)
page in the [content management](https://gohugo.io/content-management/shortcodes/)
section. Understanding the usage details will help you design and create better templates.
Introduction
------------
Hugo provides [embedded shortcodes](https://gohugo.io/shortcodes/)
for many common tasks, but you’ll likely need to create your own for more specific needs. Some examples of custom shortcodes you might develop include:
* Audio players
* Video players
* Image galleries
* Diagrams
* Maps
* Tables
* And many other custom elements
Directory structure
-------------------
Create _shortcode_ templates within the `layouts/_shortcodes` directory, either at its root or organized into subdirectories.
layouts/
└── _shortcodes/
├── diagrams/
│ ├── kroki.html
│ └── plotly.html
├── media/
│ ├── audio.html
│ ├── gallery.html
│ └── video.html
├── capture.html
├── column.html
├── include.html
└── row.html
When calling a shortcode in a subdirectory, specify its path relative to the `_shortcode` directory, excluding the file extension.
{{< media/audio path=/audio/podcast/episode-42.mp3 >}}
Lookup order
------------
Hugo selects _shortcode_ templates based on the shortcode name, the current output format, and the current language. The examples below are sorted by specificity in descending order. The least specific path is at the bottom of the list.
| Shortcode name | Output format | Language | Template path |
| --- | --- | --- | --- |
| foo | html | en | `layouts/_shortcodes/foo.en.html` |
| foo | html | en | `layouts/_shortcodes/foo.html.html` |
| foo | html | en | `layouts/_shortcodes/foo.html` |
| foo | html | en | `layouts/_shortcodes/foo.html.en.html` |
| Shortcode name | Output format | Language | Template path |
| --- | --- | --- | --- |
| foo | rss | en | `layouts/_shortcodes/foo.en.rss.xml` |
| foo | rss | en | `layouts/_shortcodes/foo.rss.xml` |
| foo | rss | en | `layouts/_shortcodes/foo.en.xml` |
| foo | rss | en | `layouts/_shortcodes/foo.xml` |
Methods
-------
Use these methods in your _shortcode_ templates. Refer to each methods’s documentation for details and examples.
[Get](https://gohugo.io/methods/shortcode/get/)
Returns the value of the given argument.
[Inner](https://gohugo.io/methods/shortcode/inner/)
Returns the content between opening and closing shortcode tags, applicable when the shortcode call includes a closing tag.
[InnerDeindent](https://gohugo.io/methods/shortcode/innerdeindent/)
Returns the content between opening and closing shortcode tags, with indentation removed, applicable when the shortcode call includes a closing tag.
[IsNamedParams](https://gohugo.io/methods/shortcode/isnamedparams/)
Reports whether the shortcode call uses named arguments.
[Name](https://gohugo.io/methods/shortcode/name/)
Returns the shortcode file name, excluding the file extension.
[Ordinal](https://gohugo.io/methods/shortcode/ordinal/)
Returns the zero-based ordinal of the shortcode in relation to its parent.
[Page](https://gohugo.io/methods/shortcode/page/)
Returns the Page object from which the shortcode was called.
[Params](https://gohugo.io/methods/shortcode/params/)
Returns a collection of the shortcode arguments.
[Parent](https://gohugo.io/methods/shortcode/parent/)
Returns the parent shortcode context in nested shortcodes.
[Position](https://gohugo.io/methods/shortcode/position/)
Returns the file name and position from which the shortcode was called.
[Ref](https://gohugo.io/methods/shortcode/ref/)
Returns the absolute URL of the page with the given path, language, and output format.
[RelRef](https://gohugo.io/methods/shortcode/relref/)
Returns the relative URL of the page with the given path, language, and output format.
[Scratch](https://gohugo.io/methods/shortcode/scratch/)
Returns a "scratch pad" to store and manipulate data, scoped to the current shortcode.
[Site](https://gohugo.io/methods/shortcode/site/)
Returns the Site object.
[Store](https://gohugo.io/methods/shortcode/store/)
Returns a "scratch pad" to store and manipulate data, scoped to the current shortcode.
Examples
--------
These examples range in complexity from simple to moderately advanced, with some simplified for clarity.
### Insert year
Create a shortcode to insert the current year:
layouts/\_shortcodes/year.html
{{- now.Format "2006" -}}
Then call the shortcode from within your markup:
content/example.md
This is {{< year >}}, and look at how far we've come.
This shortcode can be used inline or as a block on its own line. If a shortcode might be used inline, remove the surrounding [whitespace](https://gohugo.io/templates/introduction/#whitespace)
by using [template action](https://gohugo.io/quick-reference/glossary/#template-action)
delimiters with hyphens.
### Insert image
This example assumes the following content structure, where `content/example/index.md` is a [page bundle](https://gohugo.io/quick-reference/glossary/#page-bundle)
containing one or more [page resources](https://gohugo.io/quick-reference/glossary/#page-resource)
.
content/
├── example/
│ ├── a.jpg
│ └── index.md
└── _index.md
Create a shortcode to capture an image as a page resource, resize it to the given width, convert it to the WebP format, and add an `alt` attribute:
layouts/\_shortcodes/image.html
{{- with .Page.Resources.Get (.Get "path") }}
{{- with .Process (printf "resize %dx wepb" ($.Get "width")) -}}
{{- end }}
{{- end -}}
Then call the shortcode from within your markup:
content/example/index.md
{{< image path=a.jpg width=300 alt="A white kitten" >}}
The example above uses:
* The [`with`](https://gohugo.io/functions/go-template/with/)
statement to rebind the [context](https://gohugo.io/quick-reference/glossary/#context)
after each successful operation
* The [`Get`](https://gohugo.io/methods/shortcode/get/)
method to retrieve arguments by name
* The `$` to access the template context
Make sure that you thoroughly understand the concept of context. The most common templating errors made by new users relate to context.
Read more about context in the [introduction to templating](https://gohugo.io/templates/introduction/)
.
### Insert image with error handling
The previous example, while functional, silently fails if the image is missing, and does not gracefully exit if a required argument is missing. We’ll add error handling to address these issues:
layouts/\_shortcodes/image.html
{{- with .Get "path" }}
{{- with $r := $.Page.Resources.Get ($.Get "path") }}
{{- with $.Get "width" }}
{{- with $r.Process (printf "resize %dx wepb" ($.Get "width" )) }}
{{- $alt := or ($.Get "alt") "" -}}
{{- end }}
{{- else }}
{{- errorf "The %q shortcode requires a 'width' argument: see %s" $.Name $.Position }}
{{- end }}
{{- else }}
{{- warnf "The %q shortcode was unable to find %s: see %s" $.Name ($.Get "path") $.Position }}
{{- end }}
{{- else }}
{{- errorf "The %q shortcode requires a 'path' argument: see %s" .Name .Position }}
{{- end -}}
This template throws an error and gracefully fails the build if the author neglected to provide a `path` or `width` argument, and it emits a warning if it cannot find the image at the specified path. If the author does not provide an `alt` argument, the `alt` attribute is set to an empty string.
The [`Name`](https://gohugo.io/methods/shortcode/name/)
and [`Position`](https://gohugo.io/methods/shortcode/position/)
methods provide helpful context for errors and warnings. For example, a missing `width` argument causes the shortcode to throw this error:
ERROR The "image" shortcode requires a 'width' argument: see "/home/user/project/content/example/index.md:7:1"
### Positional arguments
Shortcode arguments can be [named or positional](https://gohugo.io/content-management/shortcodes/#arguments)
. We used named arguments previously; let’s explore positional arguments. Here’s the named argument version of our example:
content/example/index.md
{{< image path=a.jpg width=300 alt="A white kitten" >}}
Here’s how to call it with positional arguments:
content/example/index.md
{{< image a.jpg 300 "A white kitten" >}}
Using the `Get` method with zero-indexed keys, we’ll initialize variables with descriptive names in our template:
layouts/\_shortcodes/image.html
{{ $path := .Get 0 }}
{{ $width := .Get 1 }}
{{ $alt := .Get 2 }}
Positional arguments work well for frequently used shortcodes with one or two arguments. Since you’ll use them often, the argument order will be easy to remember. For less frequently used shortcodes, or those with more than two arguments, named arguments improve readability and reduce the chance of errors.
### Named and positional arguments
You can create a shortcode that will accept both named and positional arguments, but not at the same time. Use the [`IsNamedParams`](https://gohugo.io/methods/shortcode/isnamedparams/)
method to determine whether the shortcode call used named or positional arguments:
layouts/\_shortcodes/image.html
{{ $path := cond (.IsNamedParams) (.Get "path") (.Get 0) }}
{{ $width := cond (.IsNamedParams) (.Get "width") (.Get 1) }}
{{ $alt := cond (.IsNamedParams) (.Get "alt") (.Get 2) }}
This example uses the `cond` alias for the [`compare.Conditional`](https://gohugo.io/functions/compare/conditional/)
function to get the argument by name if `IsNamedParams` returns `true`, otherwise get the argument by position.
### Argument collection
Use the [`Params`](https://gohugo.io/methods/shortcode/params/)
method to access the arguments as a collection.
When using named arguments, the `Params` method returns a map:
content/example/index.md
{{< image path=a.jpg width=300 alt="A white kitten" >}}
layouts/\_shortcodes/image.html
{{ .Params.path }} → a.jpg
{{ .Params.width }} → 300
{{ .Params.alt }} → A white kitten
When using positional arguments, the `Params` method returns a slice:
content/example/index.md
{{< image a.jpg 300 "A white kitten" >}}
layouts/\_shortcodes/image.html
{{ index .Params 0 }} → a.jpg
{{ index .Params 1 }} → 300
{{ index .Params 1 }} → A white kitten
Combine the `Params` method with the [`collections.IsSet`](https://gohugo.io/functions/collections/isset/)
function to determine if a parameter is set, even if its value is falsy.
### Inner content
Extract the content enclosed within shortcode tags using the [`Inner`](https://gohugo.io/methods/shortcode/inner/)
method. This example demonstrates how to pass both content and a title to a shortcode. The shortcode then generates a `div` element containing an `h2` element (displaying the title) and the provided content.
content/example.md
{{< contrived title="A Contrived Example" >}}
This is a **bold** word, and this is an _emphasized_ word.
{{< /contrived >}}
layouts/\_shortcodes/contrived.html
{{ .Get "title" }}
{{ .Inner | .Page.RenderString }}
The preceding example called the shortcode using [standard notation](https://gohugo.io/content-management/shortcodes/#standard-notation)
, requiring us to process the inner content with the [`RenderString`](https://gohugo.io/methods/page/renderstring/)
method to convert the Markdown to HTML. This conversion is unnecessary when calling a shortcode using [Markdown notation](https://gohugo.io/content-management/shortcodes/#markdown-notation)
.
### Nesting
The [`Parent`](https://gohugo.io/methods/shortcode/parent/)
method provides access to the parent shortcode context when the shortcode in question is called within the context of a parent shortcode. This provides an inheritance model.
The following example is contrived but demonstrates the concept. Assume you have a `gallery` shortcode that expects one named `class` argument:
layouts/\_shortcodes/gallery.html
{{ .Inner }}
You also have an `img` shortcode with a single named `src` argument that you want to call inside of `gallery` and other shortcodes, so that the parent defines the context of each `img`:
layouts/\_shortcodes/img.html
{{ $src := .Get "src" }}
{{ with .Parent }}
{{ else }}
{{ end }}
You can then call your shortcode in your content as follows:
content/example.md
{{< gallery class="content-gallery" >}}
{{< img src="/images/one.jpg" >}}
{{< img src="/images/two.jpg" >}}
{{< /gallery >}}
{{< img src="/images/three.jpg" >}}
This will output the following HTML. Note how the first two `img` shortcodes inherit the `class` value of `content-gallery` set with the call to the parent `gallery`, whereas the third `img` only uses `src`:
### Other examples
For guidance, consider examining Hugo’s embedded shortcodes. The source code, available on [GitHub](https://github.com/gohugoio/hugo/tree/master/tpl/tplimpl/embedded/templates/_shortcodes)
, can provide a useful model.
Detection
---------
The [`HasShortcode`](https://gohugo.io/methods/page/hasshortcode/)
method allows you to check if a specific shortcode has been called on a page. For example, consider a custom audio shortcode:
content/example.md
{{< audio src=/audio/test.mp3 >}}
You can use the `HasShortcode` method in your base template to conditionally load CSS if the audio shortcode was used on the page:
layouts/baseof.html
...
{{ if .HasShortcode "audio" }}
{{ end }}
...
* * *
Last updated: February 27, 2026 : [content: Miscellaneous udpates for v0.157.0 (35da1aa3c)](https://github.com/gohugoio/hugoDocs/commit/35da1aa3c2fe3b54bdb57df1a308533844af9df5)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/shortcode.md)
---
# Pagination
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Split a list page into two or more subsets.
Displaying a large page collection on a list page is not user-friendly:
* A massive list can be intimidating and difficult to navigate. Users may get lost in the sheer volume of information.
* Large pages take longer to load, which can frustrate users and lead to them abandoning the site.
* Without any filtering or organization, finding a specific item becomes a tedious scrolling exercise.
Improve usability by paginating `home`, `section`, `taxonomy`, and `term` pages.
The most common templating mistake related to pagination is invoking pagination more than once for a given list page. See the [caching](https://gohugo.io/templates/pagination/#caching)
section below.
Terminology
-----------
paginate
To split a [list page](https://gohugo.io/quick-reference/glossary/#list-page)
into two or more subsets.
pagination
The process of paginating a list page.
pager
Created during pagination, a pager contains a subset of a list page and navigation links to other pagers.
paginator
A collection of pagers.
Configuration
-------------
See [configure pagination](https://gohugo.io/configuration/pagination/)
.
Methods
-------
To paginate a `home`, `section`, `taxonomy`, or `term` page, invoke either of these methods on the `Page` object in the corresponding template:
* [`Paginate`](https://gohugo.io/methods/page/paginate/)
* [`Paginator`](https://gohugo.io/methods/page/paginator/)
The `Paginate` method is more flexible, allowing you to:
* Paginate any page collection
* Filter, sort, and group the page collection
* Override the number of pages per pager as defined in your project configuration
By comparison, the `Paginator` method paginates the page collection passed into the template, and you cannot override the number of pages per pager.
Examples
--------
To paginate a list page using the `Paginate` method:
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages.ByTitle 7 }}
{{ range $paginator.Pages }}
{{ end }}
{{ partial "pagination.html" . }}
In the example above, we:
1. Build a page collection
2. Sort the page collection by title
3. Paginate the page collection, with 7 pages per pager
4. Range over the paginated page collection, rendering a link to each page
5. Call the embedded pagination template to create navigation links between pagers
To paginate a list page using the `Paginator` method:
{{ range .Paginator.Pages }}
{{ end }}
{{ partial "pagination.html" . }}
In the example above, we:
1. Paginate the page collection passed into the template, with the default number of pages per pager
2. Range over the paginated page collection, rendering a link to each page
3. Call the embedded pagination template to create navigation links between pagers
Caching
-------
The most common templating mistake related to pagination is invoking pagination more than once for a given list page.
Regardless of pagination method, the initial invocation is cached and cannot be changed. If you invoke pagination more than once for a given list page, subsequent invocations use the cached result. This means that subsequent invocations will not behave as written.
When paginating conditionally, do not use the `compare.Conditional` function due to its eager evaluation of arguments. Use an `if-else` construct instead.
Grouping
--------
Use pagination with any of the [grouping methods](https://gohugo.io/quick-reference/page-collections/#group)
. For example:
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate ($pages.GroupByDate "Jan 2006") }}
{{ range $paginator.PageGroups }}
{{ end }}
{{ end }}
{{ partial "pagination.html" . }}
Navigation
----------
As shown in the examples above, the easiest way to add navigation between pagers is with Hugo’s embedded pagination template:
{{ partial "pagination.html" . }}
The embedded pagination template has two formats: `default` and `terse`. The above is equivalent to:
{{ partial "pagination.html" (dict "page" . "format" "default") }}
The `terse` format has fewer controls and page slots, consuming less space when styled as a horizontal list. To use the `terse` format:
{{ partial "pagination.html" (dict "page" . "format" "terse") }}
To override Hugo’s embedded pagination template, copy the [source code](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/pagination.html)
to a file with the same name in the `layouts/_partials` directory, then call it from your templates using the [`partial`](https://gohugo.io/functions/partials/include/)
function:
`{{ partial "pagination.html" . }}`
Create custom navigation components using any of the `Pager` methods:
[First](https://gohugo.io/methods/pager/first/)
Returns the first pager in the pager collection.
[HasNext](https://gohugo.io/methods/pager/hasnext/)
Reports whether there is a pager after the current pager.
[HasPrev](https://gohugo.io/methods/pager/hasprev/)
Reports whether there is a pager before the current pager.
[Last](https://gohugo.io/methods/pager/last/)
Returns the last pager in the pager collection.
[Next](https://gohugo.io/methods/pager/next/)
Returns the next pager in the pager collection.
[NumberOfElements](https://gohugo.io/methods/pager/numberofelements/)
Returns the number of pages in the current pager.
[PageGroups](https://gohugo.io/methods/pager/pagegroups/)
Returns the page groups in the current pager.
[PageNumber](https://gohugo.io/methods/pager/pagenumber/)
Returns the current pager's number within the pager collection.
[Pagers](https://gohugo.io/methods/pager/pagers/)
Returns the pagers collection.
[PagerSize](https://gohugo.io/methods/pager/pagersize/)
Returns the number of pages per pager.
[Pages](https://gohugo.io/methods/pager/pages/)
Returns the pages in the current pager.
[PageSize](https://gohugo.io/methods/pager/pagesize/)
Returns the number of pages per pager.
[Prev](https://gohugo.io/methods/pager/prev/)
Returns the previous pager in the pager collection.
[TotalNumberOfElements](https://gohugo.io/methods/pager/totalnumberofelements/)
Returns the number of pages in the pager collection.
[TotalPages](https://gohugo.io/methods/pager/totalpages/)
Returns the number of pagers in the pager collection.
[URL](https://gohugo.io/methods/pager/url/)
Returns the URL of the current pager relative to the site root.
Structure
---------
The example below depicts the published site structure when paginating a list page.
With this content:
content/
├── posts/
│ ├── _index.md
│ ├── post-1.md
│ ├── post-2.md
│ ├── post-3.md
│ └── post-4.md
└── _index.md
And this project configuration:
pagination:
disableAliases: false
pagerSize: 2
path: page
[pagination]
disableAliases = false
pagerSize = 2
path = 'page'
{
"pagination": {
"disableAliases": false,
"pagerSize": 2,
"path": "page"
}
}
And this _section_ template:
layouts/section.html
{{ range (.Paginate .Pages).Pages }}
{{ end }}
{{ partial "pagination.html" . }}
The published site has this structure:
public/
├── posts/
│ ├── page/
│ │ ├── 1/
│ │ │ └── index.html <-- alias to public/posts/index.html
│ │ └── 2/
│ │ └── index.html
│ ├── post-1/
│ │ └── index.html
│ ├── post-2/
│ │ └── index.html
│ ├── post-3/
│ │ └── index.html
│ ├── post-4/
│ │ └── index.html
│ └── index.html
└── index.html
To disable alias generation for the first pager, change your project configuration:
pagination:
disableAliases: true
pagerSize: 2
path: page
[pagination]
disableAliases = true
pagerSize = 2
path = 'page'
{
"pagination": {
"disableAliases": true,
"pagerSize": 2,
"path": "page"
}
}
Now the published site will have this structure:
public/
├── posts/
│ ├── page/
│ │ └── 2/
│ │ └── index.html
│ ├── post-1/
│ │ └── index.html
│ ├── post-2/
│ │ └── index.html
│ ├── post-3/
│ │ └── index.html
│ ├── post-4/
│ │ └── index.html
│ └── index.html
└── index.html
* * *
Last updated: February 27, 2026 : [content: Miscellaneous udpates for v0.157.0 (35da1aa3c)](https://github.com/gohugoio/hugoDocs/commit/35da1aa3c2fe3b54bdb57df1a308533844af9df5)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/templates/pagination.md)
---
# compare.Default
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the second argument if set, else the first argument.
Syntax
compare.Default DEFAULT INPUT
Returns
any
Alias
default
The `default` function returns the second argument if set, else the first argument.
When the second argument is the boolean `false` value, the `default` function returns `false`. All _other_ falsy values are considered unset.
The falsy values are `false`, `0`, any `nil` pointer or interface value, any array, slice, map, or string of length zero, and zero `time.Time` values.
Everything else is truthy.
To set a default value based on truthiness, use the [`or`](https://gohugo.io/functions/go-template/or/)
operator instead.
The `default` function returns the second argument if set:
{{ default 42 1 }} → 1
{{ default 42 "foo" }} → foo
{{ default 42 (dict "k" "v") }} → map[k:v]
{{ default 42 (slice "a" "b") }} → [a b]
{{ default 42 true }} → true
{{ default 42 false }} → false
The `default` function returns the first argument if the second argument is not set:
{{ default 42 0 }} → 42
{{ default 42 "" }} → 42
{{ default 42 dict }} → 42
{{ default 42 slice }} → 42
{{ default 42 nil }} → 42
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/compare/Default.md)
---
# compare.Gt
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the boolean truth of arg1 > arg2 && arg1 > arg3.
Syntax
compare.Gt ARG1 ARG2 \[ARG...\]
Returns
bool
Alias
gt
{{ gt 1 1 }} → false
{{ gt 1 2 }} → false
{{ gt 2 1 }} → true
{{ gt 1 1 1 }} → false
{{ gt 1 1 2 }} → false
{{ gt 1 2 1 }} → false
{{ gt 1 2 2 }} → false
{{ gt 2 1 1 }} → true
{{ gt 2 1 2 }} → false
{{ gt 2 2 1 }} → false
Use the `compare.Gt` function to compare other data types as well:
{{ gt "ab" "a" }} → true
{{ gt time.Now (time.AsTime "1964-12-30") }} → true
{{ gt true false }} → true
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/compare/Gt.md)
---
# compare.Eq
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the boolean truth of arg1 == arg2 || arg1 == arg3.
Syntax
compare.Eq ARG1 ARG2 \[ARG...\]
Returns
bool
Alias
eq
{{ eq 1 1 }} → true
{{ eq 1 2 }} → false
{{ eq 1 1 1 }} → true
{{ eq 1 1 2 }} → true
{{ eq 1 2 1 }} → true
{{ eq 1 2 2 }} → false
You can also use the `compare.Eq` function to compare strings, boolean values, dates, slices, maps, and pages.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/compare/Eq.md)
---
# compare.Ge
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the boolean truth of arg1 >= arg2 && arg1 >= arg3.
Syntax
compare.Ge ARG1 ARG2 \[ARG...\]
Returns
bool
Alias
ge
{{ ge 1 1 }} → true
{{ ge 1 2 }} → false
{{ ge 2 1 }} → true
{{ ge 1 1 1 }} → true
{{ ge 1 1 2 }} → false
{{ ge 1 2 1 }} → false
{{ ge 1 2 2 }} → false
{{ ge 2 1 1 }} → true
{{ ge 2 1 2 }} → true
{{ ge 2 2 1 }} → true
Use the `compare.Ge` function to compare other data types as well:
{{ ge "ab" "a" }} → true
{{ ge time.Now (time.AsTime "1964-12-30") }} → true
{{ ge true false }} → true
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/compare/Ge.md)
---
# compare.Lt
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the boolean truth of arg1 < arg2 && arg1 < arg3.
Syntax
compare.Lt ARG1 ARG2 \[ARG...\]
Returns
bool
Alias
lt
{{ lt 1 1 }} → false
{{ lt 1 2 }} → true
{{ lt 2 1 }} → false
{{ lt 1 1 1 }} → false
{{ lt 1 1 2 }} → false
{{ lt 1 2 1 }} → false
{{ lt 1 2 2 }} → true
{{ lt 2 1 1 }} → false
{{ lt 2 1 2 }} → false
{{ lt 2 2 1 }} → false
Use the `compare.Lt` function to compare other data types as well:
{{ lt "ab" "a" }} → false
{{ lt time.Now (time.AsTime "1964-12-30") }} → false
{{ lt true false }} → false
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/compare/Lt.md)
---
# compare.Le
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the boolean truth of arg1 <= arg2 && arg1 <= arg3.
Syntax
compare.Le ARG1 ARG2 \[ARG...\]
Returns
bool
Alias
le
{{ le 1 1 }} → true
{{ le 1 2 }} → true
{{ le 2 1 }} → false
{{ le 1 1 1 }} → true
{{ le 1 1 2 }} → true
{{ le 1 2 1 }} → true
{{ le 1 2 2 }} → true
{{ le 2 1 1 }} → false
{{ le 2 1 2 }} → false
{{ le 2 2 1 }} → false
Use the `compare.Le` function to compare other data types as well:
{{ le "ab" "a" }} → false
{{ le time.Now (time.AsTime "1964-12-30") }} → false
{{ le true false }} → false
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/compare/Le.md)
---
# Crypto functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### crypto.FNV32a\
\
crypto.FNV32a STRING\
\
Returns the 32-bit FNV (Fowler-Noll-Vo) non-cryptographic hash of the given string.](https://gohugo.io/functions/crypto/fnv32a/)
[### crypto.HMAC\
\
crypto.HMAC HASH\_TYPE KEY MESSAGE \[ENCODING\]\
\
Returns a cryptographic hash that uses a key to sign a message.](https://gohugo.io/functions/crypto/hmac/)
[### crypto.MD5\
\
crypto.MD5 INPUT\
\
Hashes the given input and returns its MD5 checksum encoded to a hexadecimal string.](https://gohugo.io/functions/crypto/md5/)
[### crypto.SHA1\
\
crypto.SHA1 INPUT\
\
Hashes the given input and returns its SHA1 checksum encoded to a hexadecimal string.](https://gohugo.io/functions/crypto/sha1/)
[### crypto.SHA256\
\
crypto.SHA256 INPUT\
\
Hashes the given input and returns its SHA256 checksum encoded to a hexadecimal string.](https://gohugo.io/functions/crypto/sha256/)
---
# Archetypes
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

An archetype is a template for new content.
Overview
--------
A content file consists of [front matter](https://gohugo.io/quick-reference/glossary/#front-matter)
and markup. The markup is typically Markdown, but Hugo also supports other [content formats](https://gohugo.io/quick-reference/glossary/#content-format)
. Front matter can be TOML, YAML, or JSON.
The `hugo new content` command creates a new file in the `content` directory, using an archetype as a template. This is the default archetype:
---
date: '{{ .Date }}'
draft: true
title: '{{ replace .File.ContentBaseName `-` ` ` | title }}'
---
+++
date = '{{ .Date }}'
draft = true
title = '{{ replace .File.ContentBaseName `-` ` ` | title }}'
+++
{
"date": "{{ .Date }}",
"draft": true,
"title": "{{ replace .File.ContentBaseName `-` ` ` | title }}"
}
When you create new content, Hugo evaluates the [template actions](https://gohugo.io/quick-reference/glossary/#template-action)
within the archetype. For example:
hugo new content posts/my-first-post.md
With the default archetype shown above, Hugo creates this content file:
---
date: '2023-08-24T11:49:46-07:00'
draft: true
title: My First Post
---
+++
date = '2023-08-24T11:49:46-07:00'
draft = true
title = 'My First Post'
+++
{
"date": "2023-08-24T11:49:46-07:00",
"draft": true,
"title": "My First Post"
}
You can create an archetype for one or more [content types](https://gohugo.io/quick-reference/glossary/#content-type)
. For example, use one archetype for posts, and use the default archetype for everything else:
archetypes/
├── default.md
└── posts.md
Lookup order
------------
Hugo looks for archetypes in the `archetypes` directory in the root of your project, falling back to the `archetypes` directory in themes or installed modules. An archetype for a specific content type takes precedence over the default archetype.
For example, if you have enabled a theme named `my-theme` and you run this command:
hugo new content posts/my-first-post.md
The archetype lookup order is:
1. `archetypes/posts.md`
2. `themes/my-theme/archetypes/posts.md`
3. `archetypes/default.md`
4. `themes/my-theme/archetypes/default.md`
If none of these exists, Hugo uses a built-in default archetype.
Functions and context
---------------------
You can use any template [function](https://gohugo.io/quick-reference/glossary/#function)
within an archetype. As shown above, the default archetype uses the [`replace`](https://gohugo.io/functions/strings/replace/)
function to replace hyphens with spaces when populating the title in front matter.
Archetypes receive the following [context](https://gohugo.io/quick-reference/glossary/#context)
:
Date
(`string`) The current date and time, formatted in compliance with RFC3339.
File
(`hugolib.fileInfo`) Returns file information for the current page. See [details](https://gohugo.io/methods/page/file/)
.
Type
(`string`) The [content type](https://gohugo.io/quick-reference/glossary/#content-type)
inferred from the top-level directory name, or as specified by the `--kind` flag passed to the `hugo new content` command.
Site
(`page.Site`) The current site object. See [details](https://gohugo.io/methods/site/)
.
Date format
-----------
To insert date and time with a different format, use the [`time.Now`](https://gohugo.io/functions/time/now/)
function:
---
date: '{{ time.Now.Format "2006-01-02" }}'
draft: true
title: '{{ replace .File.ContentBaseName `-` ` ` | title }}'
---
+++
date = '{{ time.Now.Format "2006-01-02" }}'
draft = true
title = '{{ replace .File.ContentBaseName `-` ` ` | title }}'
+++
{
"date": "{{ time.Now.Format \"2006-01-02\" }}",
"draft": true,
"title": "{{ replace .File.ContentBaseName `-` ` ` | title }}"
}
Include content
---------------
Although typically used as a front matter template, you can also use an archetype to populate content.
For example, in a documentation site you might have a section (content type) for functions. Every page within this section should follow the same format: a brief description, the function signature, examples, and notes. We can pre-populate the page to remind content authors of the standard format.
archetypes/functions.md
---
date: '{{ .Date }}'
draft: true
title: '{{ replace .File.ContentBaseName `-` ` ` | title }}'
---
A brief description of what the function does, using simple present tense in the third person singular form. For example:
`someFunction` returns the string `s` repeated `n` times.
## Signature
```text
func someFunction(s string, n int) string
```
## Examples
One or more practical examples, each within a fenced code block.
## Notes
Additional information to clarify as needed.
Although you can include [template actions](https://gohugo.io/quick-reference/glossary/#template-action)
within the content body, remember that Hugo evaluates these once—at the time of content creation. In most cases, place template actions in a [template](https://gohugo.io/quick-reference/glossary/#template)
where Hugo evaluates the actions every time you [build](https://gohugo.io/quick-reference/glossary/#build)
the site.
Leaf bundles
------------
You can also create archetypes for [leaf bundles](https://gohugo.io/quick-reference/glossary/#leaf-bundle)
.
For example, in a photography site you might have a section (content type) for galleries. Each gallery is leaf bundle with content and images.
Create an archetype for galleries:
archetypes/
├── galleries/
│ ├── images/
│ │ └── .gitkeep
│ └── index.md <-- same format as default.md
└── default.md
Subdirectories within an archetype must contain at least one file. Without a file, Hugo will not create the subdirectory when you create new content. The name and size of the file are irrelevant. The example above includes a `.gitkeep` file, an empty file commonly used to preserve otherwise empty directories in a Git repository.
To create a new gallery:
hugo new galleries/bryce-canyon
This produces:
content/
├── galleries/
│ └── bryce-canyon/
│ ├── images/
│ │ └── .gitkeep
│ └── index.md
└── _index.md
Specify archetype
-----------------
Use the `--kind` command line flag to specify an archetype when creating content.
For example, let’s say your site has two sections: articles and tutorials. Create an archetype for each content type:
archetypes/
├── articles.md
├── default.md
└── tutorials.md
To create an article using the articles archetype:
hugo new content articles/something.md
To create an article using the tutorials archetype:
hugo new content --kind tutorials articles/something.md
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/content-management/archetypes.md)
---
# ByExpiryDate
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by expiration date in ascending order.
Syntax
PAGES.ByExpiryDate
Returns
page.Pages
When sorting by expiration date, the value is determined by your [project configuration](https://gohugo.io/configuration/front-matter/#dates)
, defaulting to the `expiryDate` field in front matter.
{{ range .Pages.ByExpiryDate }}
{{ end }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByExpiryDate.md)
---
# ByDate
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by date in ascending order.
Syntax
PAGES.ByDate
Returns
page.Pages
When sorting by date, the value is determined by your [project configuration](https://gohugo.io/configuration/front-matter/#dates)
, defaulting to the `date` field in front matter.
{{ range .Pages.ByDate }}
{{ end }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByDate.md)
---
# ByLastmod
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by last modification date in ascending order.
Syntax
PAGES.ByLastmod
Returns
page.Pages
When sorting by last modification date, the value is determined by your [project configuration](https://gohugo.io/configuration/front-matter/#dates)
, defaulting to the `lastmod` field in front matter.
{{ range .Pages.ByLastmod }}
{{ end }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByLastmod.md)
---
# compare.Ne
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the boolean truth of arg1 != arg2 && arg1 != arg3.
Syntax
compare.Ne ARG1 ARG2 \[ARG...\]
Returns
bool
Alias
ne
{{ ne 1 1 }} → false
{{ ne 1 2 }} → true
{{ ne 1 1 1 }} → false
{{ ne 1 1 2 }} → false
{{ ne 1 2 1 }} → false
{{ ne 1 2 2 }} → true
You can also use the `compare.Ne` function to compare strings, boolean values, dates, slices, maps, and pages.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/compare/Ne.md)
---
# crypto.MD5
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hashes the given input and returns its MD5 checksum encoded to a hexadecimal string.
Syntax
crypto.MD5 INPUT
Returns
string
Alias
md5
{{ md5 "Hello world" }} → 3e25960a79dbc69b674cd4ec67a72c62
This can be useful if you want to use [Gravatar](https://en.gravatar.com/)
for generating a unique avatar:
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/crypto/MD5.md)
---
# crypto.HMAC
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a cryptographic hash that uses a key to sign a message.
Syntax
crypto.HMAC HASH\_TYPE KEY MESSAGE \[ENCODING\]
Returns
string
Alias
hmac
Set the `HASH_TYPE` argument to `md5`, `sha1`, `sha256`, or `sha512`.
Set the optional `ENCODING` argument to either `hex` (default) or `binary`.
{{ hmac "sha256" "Secret key" "Secret message" }}
5cceb491f45f8b154e20f3b0a30ed3a6ff3027d373f85c78ffe8983180b03c84
{{ hmac "sha256" "Secret key" "Secret message" "hex" }}
5cceb491f45f8b154e20f3b0a30ed3a6ff3027d373f85c78ffe8983180b03c84
{{ hmac "sha256" "Secret key" "Secret message" "binary" | base64Encode }}
XM60kfRfixVOIPOwow7Tpv8wJ9Nz+Fx4/+iYMYCwPIQ=
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/crypto/HMAC.md)
---
# crypto.SHA1
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hashes the given input and returns its SHA1 checksum encoded to a hexadecimal string.
Syntax
crypto.SHA1 INPUT
Returns
string
Alias
sha1
{{ sha1 "Hello world" }} → 7b502c3a1f48c8609ae212cdfb639dee39673f5e
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/crypto/SHA1.md)
---
# CSS functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### css.PostCSS\
\
css.PostCSS \[OPTIONS\] RESOURCE\
\
Processes the given resource with PostCSS using any PostCSS plugin.](https://gohugo.io/functions/css/postcss/)
[### css.Quoted\
\
css.Quoted STRING\
\
Returns the given string, setting its data type to indicate that it must be quoted when used in CSS.](https://gohugo.io/functions/css/quoted/)
[### css.Sass\
\
css.Sass \[OPTIONS\] RESOURCE\
\
Transpiles Sass to CSS.](https://gohugo.io/functions/css/sass/)
[### css.TailwindCSS\
\
css.TailwindCSS \[OPTIONS\] RESOURCE\
\
Processes the given resource with the Tailwind CSS CLI.](https://gohugo.io/functions/css/tailwindcss/)
[### css.Unquoted\
\
css.Unquoted STRING\
\
Returns the given string, setting its data type to indicate that it must not be quoted when used in CSS.](https://gohugo.io/functions/css/unquoted/)
---
# Debug functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### debug.Dump\
\
debug.Dump VALUE\
\
Returns an object dump as a string.](https://gohugo.io/functions/debug/dump/)
[### debug.Timer\
\
debug.Timer NAME\
\
Creates a named timer that reports elapsed time to the console.](https://gohugo.io/functions/debug/timer/)
[### debug.VisualizeSpaces\
\
debug.VisualizeSpaces STRING\
\
Returns the given string with spaces replaced by a visible string.](https://gohugo.io/functions/debug/visualizespaces/)
---
# BuildDrafts
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports reports whether draft publishing is enabled for the current build.
Syntax
SITE.BuildDrafts
Returns
bool
Deprecated in [v0.156.0](https://github.com/gohugoio/hugo/releases/tag/v0.156.0)
See [details](https://discourse.gohugo.io/t/56732)
.
* * *
Last updated: March 2, 2026 : [content: Clean up content for deprecated features (850dc5b2b)](https://github.com/gohugoio/hugoDocs/commit/850dc5b2b26b7136504b24a46d6abede248c0fed)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/site/BuildDrafts.md)
---
# ByLength
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by content length in ascending order.
Syntax
PAGES.ByLength
Returns
page.Pages
{{ range .Pages.ByLength }}
{{ end }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByLength.md)
---
# ByLinkTitle
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by link title in ascending order, falling back to title if link title is not defined.
Syntax
PAGES.ByLinkTitle
Returns
page.Pages
{{ range .Pages.ByLinkTitle }}
{{ end }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByLinkTitle.md)
---
# crypto.FNV32a
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the 32-bit FNV (Fowler-Noll-Vo) non-cryptographic hash of the given string.
Syntax
crypto.FNV32a STRING
Returns
int
Deprecated in [v0.129.0](https://github.com/gohugoio/hugo/releases/tag/v0.129.0)
Use [`hash.FNV32a`](https://gohugo.io/functions/hash/fnv32a/)
instead.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/crypto/FNV32a.md)
---
# crypto.SHA256
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hashes the given input and returns its SHA256 checksum encoded to a hexadecimal string.
Syntax
crypto.SHA256 INPUT
Returns
string
Alias
sha256
{{ sha256 "Hello world" }} → 64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/crypto/SHA256.md)
---
# debug.Dump
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns an object dump as a string.
Syntax
debug.Dump VALUE
Returns
string
{{ debug.Dump hugo.Data.books }}
[\
{\
"author": "Victor Hugo",\
"rating": 4,\
"title": "The Hunchback of Notre Dame"\
},\
{\
"author": "Victor Hugo",\
"rating": 5,\
"title": "Les Misérables"\
}\
]
Output from this function may change from one release to the next. Use for debugging only.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/debug/Dump.md)
---
# debug.Timer
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Creates a named timer that reports elapsed time to the console.
Syntax
debug.Timer NAME
Returns
debug.Timer
Use the `debug.Timer` function to determine execution time for a block of code, useful for finding performance bottlenecks in templates.
The timer starts when you instantiate it, and stops when you call its `Stop` method.
{{ $t := debug.Timer "TestSqrt" }}
{{ range 2000 }}
{{ $f := math.Sqrt . }}
{{ end }}
{{ $t.Stop }}
Use the `--logLevel info` command line flag when you build the site.
hugo build --logLevel info
The results are displayed in the console at the end of the build. You can have as many timers as you want and if you don’t stop them, they will be stopped at the end of build.
INFO timer: name TestSqrt count 1002 duration 2.496017496s average 2.491035ms median 2.282291ms
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/debug/Timer.md)
---
# Diagram functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### diagrams.Goat\
\
diagrams.Goat MARKUP\
\
Returns an SVGDiagram object created from the given GoAT markup and options.](https://gohugo.io/functions/diagrams/goat/)
---
# ByPublishDate
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by publish date in ascending order.
Syntax
PAGES.ByPublishDate
Returns
page.Pages
When sorting by publish date, the value is determined by your [project configuration](https://gohugo.io/configuration/front-matter/#dates)
, defaulting to the `publishDate` field in front matter.
{{ range .Pages.ByPublishDate }}
{{ end }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByPublishDate.md)
---
# ByParam
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by the given parameter in ascending order.
Syntax
PAGES.ByParam PARAM
Returns
page.Pages
If the given parameter is not present in front matter, Hugo will use the matching parameter in your project configuration if present.
{{ range .Pages.ByParam "author" }}
{{ end }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByParam.md)
---
# Concat
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Bundle any number of assets into one resource.
See the [`resources.Concat`](https://gohugo.io/functions/resources/concat/)
function.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/hugo-pipes/bundling.md)
---
# css.Quoted
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given string, setting its data type to indicate that it must be quoted when used in CSS.
Syntax
css.Quoted STRING
Returns
css.QuotedString
This function is only applicable to the [`vars`](https://gohugo.io/functions/css/sass/#vars)
option passed to the [`css.Sass`](https://gohugo.io/functions/css/sass/)
function.
When passing a `vars` map to the `css.Sass` function, Hugo detects common typed CSS values such as `24px` or `#FF0000` using regular expression matching. If necessary, you can bypass automatic type inference by using the `css.Quoted` function to explicitly indicate that the value must be treated as a quoted string.
For example:
assets/sass/main.scss
@use "hugo:vars" as h;
ol li::after {
content: h.$ol-li-after;
}
ul li::after {
content: h.$ul-li-after;
}
layouts/\_partials/css.html
{{ $vars := dict
"ol_li_after" ("6" | css.Quoted )
"ul_li_after" ("7" | css.Quoted )
}}
{{ with resources.Get "sass/main.scss" }}
{{ $opts := dict
"enableSourceMap" hugo.IsDevelopment
"outputStyle" (cond hugo.IsDevelopment "expanded" "compressed")
"targetPath" "css/main.css"
"transpiler" "dartsass"
"vars" $vars
}}
{{ with . | toCSS $opts }}
{{ if hugo.IsDevelopment }}
{{ else }}
{{ with . | fingerprint }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
The Sass code is transpiled to:
public/css/main.css
ol li::after {
content: "6";
}
ul li::after {
content: "7";
}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/css/Quoted.md)
---
# debug.VisualizeSpaces
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given string with spaces replaced by a visible string.
Syntax
debug.VisualizeSpaces STRING
Returns
string
{{ debug.VisualizeSpaces "foo bar" }} → foo[SPACE][SPACE]bar
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/debug/VisualizeSpaces.md)
---
# ByTitle
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by title in ascending order.
Syntax
PAGES.ByTitle
Returns
page.Pages
{{ range .Pages.ByTitle }}
{{ end }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByTitle.md)
---
# ByWeight
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by weight in ascending order.
Syntax
PAGES.ByWeight
Returns
page.Pages
Assign a [weight](https://gohugo.io/quick-reference/glossary/#weight)
to a page using the `weight` field in front matter. The weight must be a non-zero integer. Lighter items float to the top, while heavier items sink to the bottom. Unweighted or zero-weighted pages are placed at the end of the collection.
{{ range .Pages.ByWeight }}
{{ end }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByWeight.md)
---
# Count
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the number of number of weighted pages to which the given term has been assigned.
Syntax
TAXONOMY.Count TERM
Returns
int
The `Count` method on a `Taxonomy` object returns the number of number of [weighted pages](https://gohugo.io/quick-reference/glossary/#weighted-page)
to which the given [term](https://gohugo.io/quick-reference/glossary/#term)
has been assigned.
Before we can use a `Taxonomy` method, we need to capture a `Taxonomy` object.
Capture a Taxonomy object
-------------------------
Consider this project configuration:
taxonomies:
author: authors
genre: genres
[taxonomies]
author = 'authors'
genre = 'genres'
{
"taxonomies": {
"author": "authors",
"genre": "genres"
}
}
And this content structure:
content/
├── books/
│ ├── and-then-there-were-none.md --> genres: suspense
│ ├── death-on-the-nile.md --> genres: suspense
│ └── jamaica-inn.md --> genres: suspense, romance
│ └── pride-and-prejudice.md --> genres: romance
└── _index.md
To capture the “genres” `Taxonomy` object from within any template, use the [`Taxonomies`](https://gohugo.io/methods/site/taxonomies/)
method on a `Site` object.
{{ $taxonomyObject := .Site.Taxonomies.genres }}
To capture the “genres” `Taxonomy` object when rendering its page with a _taxonomy_ template, use the [`Terms`](https://gohugo.io/methods/page/data/#in-a-taxonomy-template)
method on the page’s [`Data`](https://gohugo.io/methods/page/data/)
object:
layouts/taxonomy.html
{{ $taxonomyObject := .Data.Terms }}
To inspect the data structure:
{{ debug.Dump $taxonomyObject }}
Although the [`Alphabetical`](https://gohugo.io/methods/taxonomy/alphabetical/)
and [`ByCount`](https://gohugo.io/methods/taxonomy/bycount/)
methods provide a better data structure for ranging through the taxonomy, you can render the weighted pages by term directly from the `Taxonomy` object:
{{ range $term, $weightedPages := $taxonomyObject }}
{{ end }}
In the example above, the first anchor element is a link to the term page.
Count the weighted pages
------------------------
Now that we have captured the “genres” `Taxonomy` object, let’s count the number of weighted pages to which the “suspense” term has been assigned:
{{ $taxonomyObject.Count "suspense" }} → 3
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/taxonomy/Count.md)
---
# css.Unquoted
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given string, setting its data type to indicate that it must not be quoted when used in CSS.
Syntax
css.Unquoted STRING
Returns
css.UnquotedString
This function is only applicable to the [`vars`](https://gohugo.io/functions/css/sass/#vars)
option passed to the [`css.Sass`](https://gohugo.io/functions/css/sass/)
function.
When passing a `vars` map to the `css.Sass` function, Hugo detects common typed CSS values such as `24px` or `#FF0000` using regular expression matching. If necessary, you can bypass automatic type inference by using the `css.Unquoted` function to explicitly indicate that the value must not be treated as a quoted string.
For example:
assets/sass/main.scss
@use "hugo:vars" as h;
h1 {
font-size: h.$font-size-h1;
}
h2 {
font-size: h.$font-size-h2;
}
layouts/\_partials/css.html
{{ $vars := dict
"font_size_h1" ("72px * 0.500" | css.Unquoted)
"font_size_h2" ("72px * 0.375" | css.Unquoted)
}}
{{ with resources.Get "sass/main.scss" }}
{{ $opts := dict
"enableSourceMap" hugo.IsDevelopment
"outputStyle" (cond hugo.IsDevelopment "expanded" "compressed")
"targetPath" "css/main.css"
"transpiler" "dartsass"
"vars" $vars
}}
{{ with . | toCSS $opts }}
{{ if hugo.IsDevelopment }}
{{ else }}
{{ with . | fingerprint }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
The Sass rules are transpiled to:
public/css/main.css
h1 {
font-size: 36px;
}
h2 {
font-size: 27px;
}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/css/Unquoted.md)
---
# css.PostCSS
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Processes the given resource with PostCSS using any PostCSS plugin.
Syntax
css.PostCSS \[OPTIONS\] RESOURCE
Returns
resource.Resource
Alias
postCSS
[New in v0.128.0](https://github.com/gohugoio/hugo/releases/tag/v0.128.0)
{{ with resources.Get "css/main.css" | postCSS }}
{{ end }}
Setup
-----
Follow the steps below to transform CSS using any of the available [PostCSS plugins](https://postcss.org/docs/postcss-plugins)
.
Step 1
Install [Node.js](https://nodejs.org/en)
.
Step 2
Install the required Node.js packages in the root of your project. For example, to add vendor prefixes to your CSS rules:
npm i -D postcss postcss-cli autoprefixer
Step 3
Create a PostCSS configuration file in the root of your project.
postcss.config.js
module.exports = {
plugins: [\
require('autoprefixer')\
]
};
If you are a Windows user, and the path to your project contains a space, you must place the PostCSS configuration within the package.json file. See [this example](https://github.com/postcss/postcss-load-config#packagejson)
and issue [#7333](https://github.com/gohugoio/hugo/issues/7333)
.
Step 4
Place your CSS file within the `assets/css` directory.
Step 5
Process the resource with PostCSS:
{{ with resources.Get "css/main.css" | postCSS }}
{{ end }}
Options
-------
The `css.PostCSS` method takes an optional map of options.
config
(`string`) The directory that contains the PostCSS configuration file. Default is the root of the project directory.
noMap
(`bool`) Whether to disable inline source maps. Default is `false`.
inlineImports
(`bool`) Whether to enable inlining of import statements. It does so recursively, but will only import a file once. URL imports (e.g. `@import url('https://fonts.googleapis.com/css?family=Open+Sans&display=swap');`) and imports with media queries will be ignored. Note that this import routine does not care about the CSS spec, so you can have @import anywhere in the file. Hugo will look for imports relative to the module mount and will respect theme overrides. Default is `false`.
skipInlineImportsNotFound
(`bool`) Whether to allow the build process to continue despite unresolved import statements, preserving the original import declarations. If you have regular CSS imports in your CSS that you want to preserve, you can either use imports with URL or media queries (Hugo does not try to resolve those) or set this option to `true`. Default is `false`."
{{ $opts := dict "config" "config-directory" "noMap" true }}
{{ with resources.Get "css/main.css" | postCSS $opts }}
{{ end }}
No configuration file
---------------------
To avoid using a PostCSS configuration file, you can specify a minimal configuration using the options map.
use
(`string`) A space-delimited list of PostCSS plugins to use.
parser
(`string`) A custom PostCSS parser.
stringifier
(`string`) A custom PostCSS stringifier.
syntax
(`string`) Custom postcss syntax.
{{ $opts := dict "use" "autoprefixer postcss-color-alpha" }}
{{ with resources.Get "css/main.css" | postCSS $opts }}
{{ end }}
Check environment
-----------------
The current Hugo environment name (set by `--environment` or in configuration or OS environment) is available in the Node context, which allows constructs like this:
const autoprefixer = require('autoprefixer');
module.exports = {
plugins: [\
process.env.HUGO_ENVIRONMENT !== 'development' ? autoprefixer : null\
]
}
* * *
Last updated: August 23, 2025 : [Merge commit 'bfa74537929f409fca841540b971125b7678963a' (6c911d1e5)](https://github.com/gohugoio/hugoDocs/commit/6c911d1e52fb9c8065c079820327f4b0e37529d4)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/css/PostCSS.md)
---
# BaseURL
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the base URL as defined in your project configuration.
Syntax
SITE.BaseURL
Returns
string
Project configuration:
baseURL: https://example.org/docs/
baseURL = 'https://example.org/docs/'
{
"baseURL": "https://example.org/docs/"
}
Template:
{{ .Site.BaseURL }} → https://example.org/docs/
There is almost never a good reason to use this method in your templates. Its usage tends to be fragile due to misconfiguration.
Use the [`absURL`](https://gohugo.io/functions/urls/absurl/)
, [`absLangURL`](https://gohugo.io/functions/urls/abslangurl/)
, [`relURL`](https://gohugo.io/functions/urls/relurl/)
, or [`relLangURL`](https://gohugo.io/functions/urls/rellangurl/)
functions instead.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/site/BaseURL.md)
---
# ByLanguage
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection sorted by language.
Syntax
PAGES.ByLanguage
Returns
page.Pages
When sorting by language, Hugo orders the page collection using the following priority:
1. Language weight (ascending)
2. Date (descending)
3. LinkTitle (ascending)
This method is rarely, if ever, needed. Page collections that already contain multiple languages, such as those returned by the [`Rotate`](https://gohugo.io/methods/page/rotate/)
, [`Translations`](https://gohugo.io/methods/page/translations/)
, or [`AllTranslations`](https://gohugo.io/methods/page/alltranslations/)
methods on a `Page` object, are already sorted by language weight.
This contrived example aggregates pages from all sites and then sorts them by language:
{{ $p := slice }}
{{ range hugo.Sites }}
{{ range .Pages }}
{{ $p = $p | append . }}
{{ end }}
{{ end }}
{{ range $p.ByLanguage }}
{{ end }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/ByLanguage.md)
---
# css.TailwindCSS
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Processes the given resource with the Tailwind CSS CLI.
Syntax
css.TailwindCSS \[OPTIONS\] RESOURCE
Returns
resource.Resource
[New in v0.128.0](https://github.com/gohugoio/hugo/releases/tag/v0.128.0)
Use the `css.TailwindCSS` function to process your Tailwind CSS files. This function uses the Tailwind CSS CLI to:
1. Scan your templates for Tailwind CSS utility class usage.
2. Compile those utility classes into standard CSS.
3. Generate an optimized CSS output file.
Use this function with Tailwind CSS v4.0 and later, which require a relatively [modern browser](https://tailwindcss.com/docs/compatibility#browser-support)
to render correctly.
Setup
-----
Step 1
Install the Tailwind CSS CLI v4.0 or later:
npm install --save-dev tailwindcss @tailwindcss/cli @tailwindcss/typography
The Tailwind CSS CLI is also available as a [standalone executable](https://github.com/tailwindlabs/tailwindcss/releases/latest)
. You must install it outside of your project directory and ensure its path is included in your system’s `PATH` environment variable.
Step 2
Add this to your project configuration:
build:
buildStats:
enable: true
cachebusters:
- source: 'assets/notwatching/hugo_stats\.json'
target: css
- source: '(postcss|tailwind)\.config\.js'
target: css
module:
mounts:
- source: assets
target: assets
- disableWatch: true
source: hugo_stats.json
target: assets/notwatching/hugo_stats.json
[build]
[build.buildStats]
enable = true
[[build.cachebusters]]
source = 'assets/notwatching/hugo_stats\.json'
target = 'css'
[[build.cachebusters]]
source = '(postcss|tailwind)\.config\.js'
target = 'css'
[module]
[[module.mounts]]
source = 'assets'
target = 'assets'
[[module.mounts]]
disableWatch = true
source = 'hugo_stats.json'
target = 'assets/notwatching/hugo_stats.json'
{
"build": {
"buildStats": {
"enable": true
},
"cachebusters": [\
{\
"source": "assets/notwatching/hugo_stats\\.json",\
"target": "css"\
},\
{\
"source": "(postcss|tailwind)\\.config\\.js",\
"target": "css"\
}\
]
},
"module": {
"mounts": [\
{\
"source": "assets",\
"target": "assets"\
},\
{\
"disableWatch": true,\
"source": "hugo_stats.json",\
"target": "assets/notwatching/hugo_stats.json"\
}\
]
}
}
Step 3
Create a CSS entry file:
assets/css/main.css
@import "tailwindcss";
@plugin "@tailwindcss/typography";
@source "hugo_stats.json";
Tailwind CSS respects `.gitignore` files. This means that if `hugo_stats.json` is listed in your `.gitignore` file, Tailwind CSS will ignore it. To make `hugo_stats.json` available to Tailwind CSS you must explicitly source it as shown in the example above.
Step 4
Create a _partial_ template to process the CSS with the Tailwind CSS CLI:
layouts/\_partials/css.html
{{ with resources.Get "css/main.css" }}
{{ $opts := dict "minify" (not hugo.IsDevelopment) }}
{{ with . | css.TailwindCSS $opts }}
{{ if hugo.IsDevelopment }}
{{ else }}
{{ with . | fingerprint }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
Step 5
Call the _partial_ template from your base template, deferring template execution until after all sites and output formats have been rendered:
layouts/baseof.html
...
{{ with (templates.Defer (dict "key" "global")) }}
{{ partial "css.html" . }}
{{ end }}
...
Options
-------
minify
(`bool`) Whether to optimize and minify the output. Default is `false`.
optimize
(`bool`) Whether to optimize the output without minifying. Default is `false`.
disableInlineImports
[New in v0.147.4](https://github.com/gohugoio/hugo/releases/tag/v0.147.4)
(`bool`) Whether to disable inlining of `@import` statements. Inlining is performed recursively, but currently once only per file. It is not possible to import the same file in different scopes (root, media query, etc.). Note that this import routine does not care about the CSS specification, so you can have `@import` statements anywhere in the file. Default is `false`.
skipInlineImportsNotFound
(`bool`) Whether to allow the build process to continue despite unresolved import statements, preserving the original import declarations. It is important to note that the inline importer does not process URL-based imports or those with media queries, and these will remain unaltered even when this option is disabled. Default is `false`.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/css/TailwindCSS.md)
---
# Development
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Contribute to the development of Hugo.
Introduction
------------
You can contribute to the Hugo project by:
* Answering questions on the [forum](https://discourse.gohugo.io/)
* Improving the [documentation](https://gohugo.io/documentation/)
* Monitoring the [issue queue](https://github.com/gohugoio/hugo/issues)
* Creating or improving [themes](https://themes.gohugo.io/)
* Squashing [bugs](https://github.com/gohugoio/hugo/issues?q=is%3Aopen+is%3Aissue+label%3ABug)
Please submit documentation issues and pull requests to the [documentation repository](https://github.com/gohugoio/hugoDocs)
.
If you have an idea for an enhancement or new feature, create a new topic on the [forum](https://discourse.gohugo.io/)
in the “Feature” category. This will help you to:
* Determine if the capability already exists
* Measure interest
* Refine the concept
If there is sufficient interest, [create a proposal](https://github.com/gohugoio/hugo/issues/new?labels=Proposal%2C+NeedsTriage&template=feature_request.md)
. Do not submit a pull request until the project lead accepts the proposal.
For a complete guide to contributing to Hugo, see the [Contribution Guide](https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md)
.
Prerequisites
-------------
To build the extended or extended/deploy edition from source you must:
1. Install [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
2. Install [Go](https://go.dev/doc/install)
version 1.24.0 or later
3. Install a C compiler, either [GCC](https://gcc.gnu.org/)
or [Clang](https://clang.llvm.org/)
4. Update your `PATH` environment variable as described in the [Go documentation](https://go.dev/doc/code#Command)
See these [detailed instructions](https://discourse.gohugo.io/t/41370)
to install GCC on Windows.
GitHub workflow
---------------
This section assumes that you have a working knowledge of Go, Git and GitHub, and are comfortable working on the command line.
Use this workflow to create and submit pull requests.
Step 1
Fork the [project repository](https://github.com/gohugoio/hugo/)
.
Step 2
Clone your fork.
Step 3
Create a new branch with a descriptive name that includes the corresponding issue number.
For a new feature:
git checkout -b feat/implement-some-feature-99999
For a bug fix:
git checkout -b fix/fix-some-bug-99999
Step 4
Make changes.
Step 5
Compile and install.
To compile and install the standard edition:
go install
To compile and install the extended edition:
CGO_ENABLED=1 go install -tags extended
To compile and install the extended/deploy edition:
CGO_ENABLED=1 go install -tags extended,withdeploy
Step 6
Test your changes:
go test ./...
Step 7
Commit your changes with a descriptive commit message:
* Provide a summary on the first line, typically 50 characters or less, followed by a blank line.
* Begin the summary with the name of the package, followed by a colon, a space, and a brief description of the change beginning with a capital letter
* Use imperative present tense
* See the [commit message guidelines](https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md#git-commit-message-guidelines)
for requirements
* Optionally, provide a detailed description where each line is 72 characters or less, followed by a blank line.
* Add one or more “Fixes” or “Closes” keywords, each on its own line, referencing the [issues](https://github.com/gohugoio/hugo/issues)
addressed by this change.
For example:
git commit -m "tpl/strings: Create wrap function
The strings.Wrap function wraps a string into one or more lines,
splitting the string after the given number of characters, but not
splitting in the middle of a word.
Fixes #99998
Closes #99999"
Step 8
Push the new branch to your fork of the documentation repository.
Step 9
Visit the [project repository](https://github.com/gohugoio/hugo/)
and create a pull request (PR).
Step 10
A project maintainer will review your PR and may request changes. You may delete your branch after the maintainer merges your PR.
Building from source
--------------------
You can build, install, and test Hugo at any point in its development history. The examples below build and install the extended edition of Hugo.
To build and install the latest release:
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest
To build and install a specific release:
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.156.0
To build and install at the latest commit on the master branch:
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@master
To build and install at a specific commit:
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@c0d9beb
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/contribute/development.md)
---
# diagrams.Goat
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns an SVGDiagram object created from the given GoAT markup and options.
Syntax
diagrams.Goat MARKUP
Returns
diagrams.SVGDiagram
Useful in a [code block render hook](https://gohugo.io/render-hooks/code-blocks/)
, the `diagrams.Goat` function returns an SVGDiagram object created from the given [GoAT](https://github.com/bep/goat)
markup.
Methods
-------
The SVGDiagram object has the following methods:
Inner
(`template.HTML`) Returns the SVG child elements without a wrapping `svg` element, allowing you to create your own wrapper.
Wrapped
(`template.HTML`) Returns the SVG child elements wrapped in an `svg` element.
Width
(`int`) Returns the width of the rendered diagram, in pixels.
Height
(`int`) Returns the height of the rendered diagram, in pixels.
GoAT Diagrams
-------------
Hugo natively supports GoAT diagrams with an [embedded code block render hook](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-codeblock-goat.html)
.
This Markdown:
```goat
.---. .-. .-. .-. .---.
| A +--->| 1 |<--->| 2 |<--->| 3 |<---+ B |
'---' '-' '+' '+' '---'
```
Is rendered to:
Which appears in your browser as:
A123B
To customize rendering, override Hugo’s [embedded code block render hook](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-codeblock-goat.html)
for GoAT diagrams.
Code block render hook
----------------------
By way of example, let’s create a code block render hook to render GoAT diagrams as `figure` elements with an optional caption.
layouts/\_markup/render-codeblock-goat.html
{{ $caption := or .Attributes.caption "" }}
{{ $class := or .Attributes.class "diagram" }}
{{ $id := or .Attributes.id (printf "diagram-%d" (add 1 .Ordinal)) }}
{{ with diagrams.Goat (trim .Inner "\n\r") }}
{{ end }}
{{ $caption }}
This Markdown:
content/example.md
```goat {class="foo" caption="Diagram 1: Example"}
.---. .-. .-. .-. .---.
| A +--->| 1 |<--->| 2 |<--->| 3 |<---+ B |
'---' '-' '+' '+' '---'
```
Is rendered to:
Diagram 1: Example
Use CSS to style the SVG as needed:
svg.foo {
font-family: "Segoe UI","Noto Sans",Helvetica,Arial,sans-serif
}
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/diagrams/Goat.md)
---
# Deprecation
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

The Hugo project follows a formal and consistent process to deprecate functions, methods, and configuration settings.
When a project _deprecates_ something, they are telling its users:
1. Don’t use Thing One anymore.
2. Use Thing Two instead.
3. We’re going to remove Thing One at some point in the future.
Common [reasons for deprecation](https://en.wikipedia.org/wiki/Deprecation)
:
* A feature has been replaced by a more powerful alternative.
* A feature contains a design flaw.
* A feature is considered extraneous, and will be removed in the future in order to simplify the system as a whole.
* A future version of the software will make major structural changes, making it impossible or impractical to support older features.
* Standardization or increased consistency in naming.
* A feature that once was available only independently is now combined with its co-feature.
After the project team deprecates something in code, Hugo will:
1. Log an INFO message for 3 minor releases[1](https://gohugo.io/troubleshooting/deprecation/#fn:1)
2. Log a WARN message for another 12 minor releases
3. Log an ERROR message and fail the build thereafter
The project team will:
1. On the deprecation date, update the documentation with a note describing the deprecation and any relevant alternatives.
2. Remove the code six or more minor releases after Hugo begins logging ERROR messages and failing the build. At that point, Hugo will throw an error, but the error message will no longer mention the deprecation.
3. Remove the corresponding documentation two years after the deprecation date.
To see the INFO messages, you must use the `--logLevel` command line flag:
hugo build --logLevel info
To limit the output to deprecation notices:
hugo build --logLevel info | grep deprecate
Run the above command every time you upgrade Hugo.
* * *
1. For example, v0.1.1 => v0.2.0 is a minor release. [↩︎](https://gohugo.io/troubleshooting/deprecation/#fnref:1)
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/troubleshooting/deprecation.md)
---
# Encoding functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### encoding.Base64Decode\
\
encoding.Base64Decode INPUT\
\
Returns the base64 decoding of the given content.](https://gohugo.io/functions/encoding/base64decode/)
[### encoding.Base64Encode\
\
encoding.Base64Encode INPUT\
\
Returns the base64 decoding of the given content.](https://gohugo.io/functions/encoding/base64encode/)
[### encoding.Jsonify\
\
encoding.Jsonify \[OPTIONS\] INPUT\
\
Encodes the given object to JSON.](https://gohugo.io/functions/encoding/jsonify/)
---
# Build options
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Build options help define how Hugo must treat a given page when building the site.
Build options are stored in a reserved front matter object named `build`[1](https://gohugo.io/content-management/build-options/#fn:1)
with these defaults:
---
build:
list: always
publishResources: true
render: always
---
+++
[build]
list = 'always'
publishResources = true
render = 'always'
+++
{
"build": {
"list": "always",
"publishResources": true,
"render": "always"
}
}
list
When to include the page within page collections. Specify one of:
* `always`: Include the page in _all_ page collections. For example, `site.RegularPages`, `.Pages`, etc. This is the default value.
* `local`: Include the page in _local_ page collections. For example, `.RegularPages`, `.Pages`, etc. Use this option to create fully navigable but headless content sections.
* `never`: Do not include the page in _any_ page collection.
publishResources
Applicable to [page bundles](https://gohugo.io/content-management/page-bundles/)
, determines whether to publish the associated [page resources](https://gohugo.io/content-management/page-resources/)
. Specify one of:
* `true`: Always publish resources. This is the default value.
* `false`: Only publish a resource when invoking its [`Permalink`](https://gohugo.io/methods/resource/permalink/)
, [`RelPermalink`](https://gohugo.io/methods/resource/relpermalink/)
, or [`Publish`](https://gohugo.io/methods/resource/publish/)
method within a template.
render
When to render the page. Specify one of:
* `always`: Always render the page to disk. This is the default value.
* `link`: Do not render the page to disk, but assign `Permalink` and `RelPermalink` values.
* `never`: Never render the page to disk, and exclude it from all page collections.
Any page, regardless of its build options, will always be available by using the [`.Page.GetPage`](https://gohugo.io/methods/page/getpage/)
or [`.Site.GetPage`](https://gohugo.io/methods/site/getpage/)
method.
Example – headless page
-----------------------
Create a unpublished page whose content and resources can be included in other pages.
content/
├── headless/
│ ├── a.jpg
│ ├── b.jpg
│ └── index.md <-- leaf bundle
└── _index.md <-- home page
Set the build options in front matter:
---
build:
list: never
publishResources: false
render: never
title: Headless page
---
+++
title = 'Headless page'
[build]
list = 'never'
publishResources = false
render = 'never'
+++
{
"build": {
"list": "never",
"publishResources": false,
"render": "never"
},
"title": "Headless page"
}
To include the content and images on the home page:
layouts/home.html
{{ with .Site.GetPage "/headless" }}
{{ .Content }}
{{ range .Resources.ByType "image" }}
{{ end }}
{{ end }}
The published site will have this structure:
public/
├── headless/
│ ├── a.jpg
│ └── b.jpg
└── index.html
In the example above, note that:
1. Hugo did not publish an HTML file for the page.
2. Despite setting `publishResources` to `false` in front matter, Hugo published the [page resources](https://gohugo.io/content-management/page-resources/)
because we invoked the [`RelPermalink`](https://gohugo.io/methods/resource/relpermalink/)
method on each resource. This is the expected behavior.
Example – headless section
--------------------------
Create a unpublished section whose content and resources can be included in other pages.
content/
├── headless/
│ ├── note-1/
│ │ ├── a.jpg
│ │ ├── b.jpg
│ │ └── index.md <-- leaf bundle
│ ├── note-2/
│ │ ├── c.jpg
│ │ ├── d.jpg
│ │ └── index.md <-- leaf bundle
│ └── _index.md <-- branch bundle
└── _index.md <-- home page
Set the build options in front matter, using the `cascade` keyword to “cascade” the values down to descendant pages.
---
cascade:
- build:
list: local
publishResources: false
render: never
title: Headless section
---
+++
title = 'Headless section'
[[cascade]]
[cascade.build]
list = 'local'
publishResources = false
render = 'never'
+++
{
"cascade": [\
{\
"build": {\
"list": "local",\
"publishResources": false,\
"render": "never"\
}\
}\
],
"title": "Headless section"
}
In the front matter above, note that we have set `list` to `local` to include the descendant pages in local page collections.
To include the content and images on the home page:
layouts/home.html
{{ with .Site.GetPage "/headless" }}
{{ range .Pages }}
{{ .Content }}
{{ range .Resources.ByType "image" }}
{{ end }}
{{ end }}
{{ end }}
The published site will have this structure:
public/
├── headless/
│ ├── note-1/
│ │ ├── a.jpg
│ │ └── b.jpg
│ └── note-2/
│ ├── c.jpg
│ └── d.jpg
└── index.html
In the example above, note that:
1. Hugo did not publish an HTML file for the page.
2. Despite setting `publishResources` to `false` in front matter, Hugo correctly published the [page resources](https://gohugo.io/content-management/page-resources/)
because we invoked the [`RelPermalink`](https://gohugo.io/methods/resource/relpermalink/)
method on each resource. This is the expected behavior.
Example – list without publishing
---------------------------------
Publish a section page without publishing the descendant pages. For example, to create a glossary:
content/
├── glossary/
│ ├── _index.md
│ ├── bar.md
│ ├── baz.md
│ └── foo.md
└── _index.md
Set the build options in front matter, using the `cascade` keyword to “cascade” the values down to descendant pages.
---
build:
render: always
cascade:
- build:
list: local
publishResources: false
render: never
title: Glossary
---
+++
title = 'Glossary'
[build]
render = 'always'
[[cascade]]
[cascade.build]
list = 'local'
publishResources = false
render = 'never'
+++
{
"build": {
"render": "always"
},
"cascade": [\
{\
"build": {\
"list": "local",\
"publishResources": false,\
"render": "never"\
}\
}\
],
"title": "Glossary"
}
To render the glossary:
layouts/glossary/section.html
{{ range .Pages }}
{{ .Title }}
{{ .Content }}
{{ end }}
The published site will have this structure:
public/
├── glossary/
│ └── index.html
└── index.html
Example – publish without listing
---------------------------------
Publish a section’s descendant pages without publishing the section page itself.
content/
├── books/
│ ├── _index.md
│ ├── book-1.md
│ └── book-2.md
└── _index.md
Set the build options in front matter:
---
build:
list: never
render: never
title: Books
---
+++
title = 'Books'
[build]
list = 'never'
render = 'never'
+++
{
"build": {
"list": "never",
"render": "never"
},
"title": "Books"
}
The published site will have this structure:
public/
├── books/
│ ├── book-1/
│ │ └── index.html
│ └── book-2/
│ └── index.html
└── index.html
Example – conditionally hide section
------------------------------------
Consider this example. A documentation site has a team of contributors with access to 20 custom shortcodes. Each shortcode takes several arguments, and requires documentation for the contributors to reference when using them.
Instead of external documentation for the shortcodes, include an “internal” section that is hidden when building the production site.
content/
├── internal/
│ ├── shortcodes/
│ │ ├── _index.md
│ │ ├── shortcode-1.md
│ │ └── shortcode-2.md
│ └── _index.md
├── reference/
│ ├── _index.md
│ ├── reference-1.md
│ └── reference-2.md
├── tutorials/
│ ├── _index.md
│ ├── tutorial-1.md
│ └── tutorial-2.md
└── _index.md
Set the build options in front matter, using the `cascade` keyword to “cascade” the values down to descendant pages, and use the `target` keyword to target the production environment.
cascade:
- build:
list: never
render: never
target:
environment: production
title: Internal
title = 'Internal'
[[cascade]]
[cascade.build]
list = 'never'
render = 'never'
[cascade.target]
environment = 'production'
{
"cascade": [\
{\
"build": {\
"list": "never",\
"render": "never"\
},\
"target": {\
"environment": "production"\
}\
}\
],
"title": "Internal"
}
The production site will have this structure:
public/
├── reference/
│ ├── reference-1/
│ │ └── index.html
│ ├── reference-2/
│ │ └── index.html
│ └── index.html
├── tutorials/
│ ├── tutorial-1/
│ │ └── index.html
│ ├── tutorial-2/
│ │ └── index.html
│ └── index.html
└── index.html
* * *
1. The `_build` alias for `build` is deprecated and will be removed in a future release. [↩︎](https://gohugo.io/content-management/build-options/#fnref:1)
* * *
Last updated: July 7, 2025 : [Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45' (079671b41)](https://github.com/gohugoio/hugoDocs/commit/079671b41b9395f2c2b48879f14d3f09d69a63dc)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/content-management/build-options.md)
---
# encoding.Base64Encode
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the base64 decoding of the given content.
Syntax
encoding.Base64Encode INPUT
Returns
string
Alias
base64Encode
{{ "Hugo" | base64Encode }} → SHVnbw==
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/encoding/Base64Encode.md)
---
# encoding.Base64Decode
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the base64 decoding of the given content.
Syntax
encoding.Base64Decode INPUT
Returns
string
Alias
base64Decode
{{ "SHVnbw==" | base64Decode }} → Hugo
Use the `base64Decode` function to decode responses from APIs. For example, the result of this call to GitHub’s API contains the base64-encoded representation of the repository’s README file:
https://api.github.com/repos/gohugoio/hugo/readme
To retrieve and render the content:
{{ $url := "https://api.github.com/repos/gohugoio/hugo/readme" }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else with .Value }}
{{ with . | transform.Unmarshal }}
{{ .content | base64Decode | markdownify }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/encoding/Base64Decode.md)
---
# encoding.Jsonify
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Encodes the given object to JSON.
Syntax
encoding.Jsonify \[OPTIONS\] INPUT
Returns
template.HTML
Alias
jsonify
To customize the printing of the JSON, pass an options map as the first argument. Supported options are “prefix” and “indent”. Each JSON element in the output will begin on a new line beginning with _prefix_ followed by one or more copies of _indent_ according to the indentation nesting.
{{ dict "title" .Title "content" .Plain | jsonify }}
{{ dict "title" .Title "content" .Plain | jsonify (dict "indent" " ") }}
{{ dict "title" .Title "content" .Plain | jsonify (dict "prefix" " " "indent" " ") }}
Options
-------
indent
(`string`) Indentation to use. Default is “”.
prefix
(`string`) Indentation prefix. Default is “”.
noHTMLEscape
(`bool`) Whether to disable escaping of problematic HTML characters inside JSON quoted strings. The default behavior is to escape `&`, `<`, and `>` to `\u0026`, `\u003c`, and `\u003e` to avoid certain safety problems that can arise when embedding JSON in HTML. Default is `false`.
* * *
Last updated: August 23, 2025 : [Merge commit 'bfa74537929f409fca841540b971125b7678963a' (6c911d1e5)](https://github.com/gohugoio/hugoDocs/commit/6c911d1e52fb9c8065c079820327f4b0e37529d4)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/encoding/Jsonify.md)
---
# Configure build
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Configure global build options.
The `build` configuration section contains global build-related configuration options.
build:
buildStats:
disableClasses: false
disableIDs: false
disableTags: false
enable: false
cacheBusters:
- source: '(postcss|tailwind)\.config\.js'
target: (css|styles|scss|sass)
noJSConfigInAssets: false
useResourceCacheWhen: fallback
[build]
noJSConfigInAssets = false
useResourceCacheWhen = 'fallback'
[build.buildStats]
disableClasses = false
disableIDs = false
disableTags = false
enable = false
[[build.cacheBusters]]
source = '(postcss|tailwind)\.config\.js'
target = '(css|styles|scss|sass)'
{
"build": {
"buildStats": {
"disableClasses": false,
"disableIDs": false,
"disableTags": false,
"enable": false
},
"cacheBusters": [\
{\
"source": "(postcss|tailwind)\\.config\\.js",\
"target": "(css|styles|scss|sass)"\
}\
],
"noJSConfigInAssets": false,
"useResourceCacheWhen": "fallback"
}
}
buildStats
See the [build stats](https://gohugo.io/configuration/build/#build-stats)
section below.
cachebusters
See the [cache busters](https://gohugo.io/configuration/build/#cache-busters)
section below.
noJSConfigInAssets
(`bool`) Whether to disable writing a `jsconfig.json` in your `assets` directory with mapping of imports from running [js.Build](https://gohugo.io/hugo-pipes/js/)
. This file is intended to help with intellisense/navigation inside code editors such as [VS Code](https://code.visualstudio.com/)
. Note that if you do not use `js.Build`, no file will be written.
useResourceCacheWhen
(`string`) When to use the resource file cache, one of `never`, `fallback`, or `always`. Applicable when transpiling Sass to CSS. Default is `fallback`.
Cache busters
-------------
The `build.cachebusters` configuration option was added to support development using Tailwind 3.x’s JIT compiler where a `build` configuration may look like this:
build:
buildStats:
enable: true
cachebusters:
- source: 'assets/watching/hugo_stats\.json'
target: 'styles\.css'
- source: '(postcss|tailwind)\.config\.js'
target: css
- source: 'assets/.*\.(js|ts|jsx|tsx)'
target: js
- source: 'assets/.*\.(.*)$'
target: $1
[build]
[build.buildStats]
enable = true
[[build.cachebusters]]
source = 'assets/watching/hugo_stats\.json'
target = 'styles\.css'
[[build.cachebusters]]
source = '(postcss|tailwind)\.config\.js'
target = 'css'
[[build.cachebusters]]
source = 'assets/.*\.(js|ts|jsx|tsx)'
target = 'js'
[[build.cachebusters]]
source = 'assets/.*\.(.*)$'
target = '$1'
{
"build": {
"buildStats": {
"enable": true
},
"cachebusters": [\
{\
"source": "assets/watching/hugo_stats\\.json",\
"target": "styles\\.css"\
},\
{\
"source": "(postcss|tailwind)\\.config\\.js",\
"target": "css"\
},\
{\
"source": "assets/.*\\.(js|ts|jsx|tsx)",\
"target": "js"\
},\
{\
"source": "assets/.*\\.(.*)$",\
"target": "$1"\
}\
]
}
}
When `buildStats` is enabled, Hugo writes a `hugo_stats.json` file on each build with HTML classes etc. that’s used in the rendered output. Changes to this file will trigger a rebuild of the `styles.css` file. You also need to add `hugo_stats.json` to Hugo’s server watcher. See [Hugo Starter Tailwind Basic](https://github.com/bep/hugo-starter-tailwind-basic)
for a running example.
source
(`string`) A [regular expression](https://gohugo.io/quick-reference/glossary/#regular-expression)
matching file(s) relative to one of the virtual component directories in Hugo, typically `assets/...`.
target
(`string`) A [regular expression](https://gohugo.io/quick-reference/glossary/#regular-expression)
matching the keys in the resource cache that should be expired when `source` changes. You can use the matching regexp groups from `source` in the expression, e.g. `$1`.
Build stats
-----------
build:
buildStats:
disableClasses: false
disableIDs: false
disableTags: false
enable: false
[build]
[build.buildStats]
disableClasses = false
disableIDs = false
disableTags = false
enable = false
{
"build": {
"buildStats": {
"disableClasses": false,
"disableIDs": false,
"disableTags": false,
"enable": false
}
}
}
enable
(`bool`) Whether to create a `hugo_stats.json` file in the root of your project. This file contains arrays of the `class` attributes, `id` attributes, and tags of every HTML element within your published site. Use this file as data source when [removing unused CSS](https://gohugo.io/functions/resources/postprocess/)
from your site. This process is also known as pruning, purging, or tree shaking. Default is `false`.
disableIDs
(`bool`) Whether to exclude `id` attributes. Default is `false`.
disableTags
(`bool`) Whether to exclude element tags. Default is `false`.
disableClasses
(`bool`) Whether to exclude `class` attributes. Default is `false`.
Given that CSS purging is typically limited to production builds, place the `buildStats` object below [`config/production`](https://gohugo.io/configuration/introduction/#configuration-directory)
.
Built for speed, there may be “false positive” detections (e.g., HTML elements that are not HTML elements) while parsing the published site. These “false positives” are infrequent and inconsequential.
Due to the nature of partial server builds, new HTML entities are added while the server is running, but old values will not be removed until you restart the server or run `hugo build`.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/configuration/build.md)
---
# Collections functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### collections.After\
\
collections.After N SLICE\
\
Returns a slice containing the elements after the first N elements of the given slice.](https://gohugo.io/functions/collections/after/)
[### collections.Append\
\
collections.Append ELEMENT \[ELEMENT...\] SLICE\
\
Returns a slice by adding one or more elements, or an entire second slice, to the end of the given slice.](https://gohugo.io/functions/collections/append/)
[### collections.Apply\
\
collections.Apply SLICE FUNCTION PARAM...\
\
Returns a slice by transforming each element of the given slice using a specific function and parameters.](https://gohugo.io/functions/collections/apply/)
[### collections.Complement\
\
collections.Complement SLICE \[SLICE...\]\
\
Returns a slice by identifying elements in the last given slice that do not appear in any of the preceding slices.](https://gohugo.io/functions/collections/complement/)
[### collections.D\
\
collections.D SEED N HIGH\
\
Returns a sorted slice of unique random integers based on a given seed, count, and maximum value.](https://gohugo.io/functions/collections/d/)
[### collections.Delimit\
\
collections.Delimit SLICE|MAP DELIMITER \[LAST\]\
\
Returns a string by joining the values of the given slice or map with a delimiter.](https://gohugo.io/functions/collections/delimit/)
[### collections.Dictionary\
\
collections.Dictionary \[VALUE...\]\
\
Returns a map created from the given key-value pairs.](https://gohugo.io/functions/collections/dictionary/)
[### collections.First\
\
collections.First N SLICE|STRING\
\
Returns the first N elements of the given slice or string.](https://gohugo.io/functions/collections/first/)
[### collections.Group\
\
collections.Group KEY PAGES\
\
Returns a map by grouping the given page collection (slice) by a specific key.](https://gohugo.io/functions/collections/group/)
[### collections.In\
\
collections.In SLICE|STRING VALUE\
\
Reports whether a value exists within the given slice or string.](https://gohugo.io/functions/collections/in/)
[### collections.Index\
\
collections.Index SLICE|MAP KEY...\
\
Returns an element or value from the given slice or map at the specified key(s).](https://gohugo.io/functions/collections/indexfunction/)
[### collections.Intersect\
\
collections.Intersect SLICE1 SLICE2\
\
Returns a slice containing the common elements found in two given slices, in the same order as the first slice.](https://gohugo.io/functions/collections/intersect/)
[### collections.IsSet\
\
collections.IsSet MAP|SLICE KEY|INDEX\
\
Reports whether a specific key or index exists in the given map or slice.](https://gohugo.io/functions/collections/isset/)
[### collections.KeyVals\
\
collections.KeyVals KEY VALUE...\
\
Returns a KeyVals struct by pairing a given key and values.](https://gohugo.io/functions/collections/keyvals/)
[### collections.Last\
\
collections.Last N SLICE|STRING\
\
Returns the last N elements of the given slice or string.](https://gohugo.io/functions/collections/last/)
[### collections.Merge\
\
collections.Merge MAP MAP...\
\
Returns a map by combining two or more given maps.](https://gohugo.io/functions/collections/merge/)
[### collections.NewScratch\
\
collections.NewScratch\
\
Returns a locally scoped "scratch pad" to store and manipulate data.](https://gohugo.io/functions/collections/newscratch/)
[### collections.Querify\
\
collections.Querify MAP|SLICE|KEY VALUE...\
\
Returns a URL query string from the given map, slice, or sequence of key-value pairs.](https://gohugo.io/functions/collections/querify/)
[### collections.Reverse\
\
collections.Reverse SLICE\
\
Returns a slice by reversing the order of elements in the given slice.](https://gohugo.io/functions/collections/reverse/)
[### collections.Seq\
\
collections.Seq LAST\
\
Returns a slice of integers starting from 1 or a given value, incrementing by 1 or a given value, and ending at a given value.](https://gohugo.io/functions/collections/seq/)
[### collections.Shuffle\
\
collections.Shuffle SLICE\
\
Returns a slice by randomizing the element order of the given slice.](https://gohugo.io/functions/collections/shuffle/)
[### collections.Slice\
\
collections.Slice \[VALUE...\]\
\
Returns a slice created from the given values.](https://gohugo.io/functions/collections/slice/)
[### collections.Sort\
\
collections.Sort MAP|SLICE \[KEY\] \[ORDER\]\
\
Returns a sorted map or slice by reordering the given collection by a key and order.](https://gohugo.io/functions/collections/sort/)
[### collections.SymDiff\
\
SLICE1 | collections.SymDiff SLICE2\
\
Returns a slice containing the symmetric difference of two given slices.](https://gohugo.io/functions/collections/symdiff/)
[### collections.Union\
\
collections.Union SLICE1 SLICE2\
\
Returns a slice containing the unique elements from two given slices.](https://gohugo.io/functions/collections/union/)
[### collections.Uniq\
\
collections.Uniq SLICE\
\
Returns a slice by removing duplicate elements from the given slice.](https://gohugo.io/functions/collections/uniq/)
[### collections.Where\
\
collections.Where SLICE KEY \[OPERATOR\] VALUE\
\
Returns a slice by filtering the given slice based on a key, operator, and value.](https://gohugo.io/functions/collections/where/)
---
# continue
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Used with the range statement, stops the innermost iteration and continues to the next iteration.
Syntax
continue
This template code:
{{ $s := slice "foo" "bar" "baz" }}
{{ range $s }}
{{ if eq . "bar" }}
{{ continue }}
{{ end }}
{{ . }}
{{ end }}
Is rendered to:
foo
baz
See Go’s [`text/template`](https://pkg.go.dev/text/template)
documentation for more information.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/go-template/continue.md)
---
# css.Sass
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Transpiles Sass to CSS.
Syntax
css.Sass \[OPTIONS\] RESOURCE
Returns
resource.Resource
Alias
toCSS
Transpile Sass to CSS using the LibSass transpiler included in Hugo’s extended and extended/deploy editions, or [install Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass)
to use the latest features of the Sass language.
The embedded LibSass transpiler was deprecated in [v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
and will be removed in a future release. Use the Dart Sass transpiler instead.
Sass has two forms of syntax: [SCSS](https://sass-lang.com/documentation/syntax#scss)
and [indented](https://sass-lang.com/documentation/syntax#the-indented-syntax)
. Hugo supports both.
Options
-------
enableSourceMap
(`bool`) Whether to generate a source map. Default is `false`.
includePaths
(`slice`) A slice of paths, relative to the project root, that the transpiler will use when resolving `@use` and `@import` statements.
outputStyle
(`string`) The output style of the resulting CSS. With LibSass, one of `nested` (default), `expanded`, `compact`, or `compressed`. With Dart Sass, either `expanded` (default) or `compressed`.
precision
(`int`) The precision of floating point math. Applicable to LibSass. Default is `8`.
silenceDeprecations
[New in v0.139.0](https://github.com/gohugoio/hugo/releases/tag/v0.139.0)
(`slice`) A slice of deprecation IDs to silence. IDs are enclosed in brackets within Dart Sass warning messages (e.g., `import` in `WARN Dart Sass: DEPRECATED [import]`). Applicable to Dart Sass. Default is `false`.
silenceDependencyDeprecations
[New in v0.146.0](https://github.com/gohugoio/hugo/releases/tag/v0.146.0)
(`bool`) Whether to silence deprecation warnings from dependencies, where a dependency is considered any file transitively imported through a load path. This does not apply to `@warn` or `@debug` rules.Default is `false`.
sourceMapIncludeSources
(`bool`) Whether to embed sources in the generated source map. Applicable to Dart Sass. Default is `false`.
targetPath
(`string`) The publish path for the transformed resource, relative to the[`publishDir`](https://gohugo.io/configuration/all/#publishdir)
. If unset, the target path defaults to the asset’s original path with a `.css` extension.
transpiler
(`string`) The transpiler to use, either `libsass` or `dartsass`. Hugo’s extended and extended/deploy editions include the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](https://gohugo.io/functions/css/sass/#dart-sass)
. Default is `libsass`.
The embedded LibSass transpiler was deprecated in [v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
and will be removed in a future release. Use the Dart Sass transpiler instead.
vars
(`map`) A map of key-value pairs that will be available in the `hugo:vars` namespace. Useful for [initializing Sass variables from Hugo templates](https://discourse.gohugo.io/t/42053/)
.
// LibSass
@import "hugo:vars";
// Dart Sass
@use "hugo:vars" as v;
When passing a `vars` map to the `css.Sass` function, Hugo detects common typed CSS values such as `24px` or `#FF0000` using regular expression matching. If necessary, you can bypass automatic type inference by using the [`css.Quoted`](https://gohugo.io/functions/css/quoted/)
or [`css.Unquoted`](https://gohugo.io/functions/css/unquoted/)
function to explicitly indicate a value’s type.
Example
-------
{{ with resources.Get "sass/main.scss" }}
{{ $opts := dict
"enableSourceMap" hugo.IsDevelopment
"outputStyle" (cond hugo.IsDevelopment "expanded" "compressed")
"targetPath" "css/main.css"
"transpiler" "dartsass"
"vars" site.Params.styles
"includePaths" (slice "node_modules/bootstrap/scss")
}}
{{ with . | toCSS $opts }}
{{ if hugo.IsDevelopment }}
{{ else }}
{{ with . | fingerprint }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
Dart Sass
---------
Hugo’s extended and extended/deploy editions include [LibSass](https://sass-lang.com/libsass)
to transpile Sass to CSS. In 2020, the Sass team deprecated LibSass in favor of [Dart Sass](https://sass-lang.com/dart-sass/)
.
Use the latest features of the Sass language by installing Dart Sass in your development and production environments.
### Installation overview
Dart Sass is compatible with Hugo v0.114.0 and later.
If you have been using Embedded Dart Sass[1](https://gohugo.io/functions/css/sass/#fn:1)
with Hugo v0.113.0 and earlier, uninstall Embedded Dart Sass, then install Dart Sass. If you have installed both, Hugo will use Dart Sass.
If you install Hugo as a [Snap package](https://snapcraft.io/hugo)
there is no need to install Dart Sass. The Hugo Snap package includes Dart Sass.
### Installing in a development environment
When you install Dart Sass somewhere in your PATH, Hugo will find it.
| OS | Package manager | Site | Installation |
| --- | --- | --- | --- |
| Linux | Homebrew | [brew.sh](https://brew.sh/) | `brew install sass/sass/sass` |
| Linux | Snap | [snapcraft.io](https://snapcraft.io/dart-sass) | `sudo snap install dart-sass` |
| macOS | Homebrew | [brew.sh](https://brew.sh/) | `brew install sass/sass/sass` |
| Windows | Chocolatey | [chocolatey.org](https://community.chocolatey.org/packages/sass) | `choco install sass` |
| Windows | Scoop | [scoop.sh](https://scoop.sh/#/apps?q=sass) | `scoop install sass` |
You may also install [prebuilt binaries](https://github.com/sass/dart-sass/releases/latest)
for Linux, macOS, and Windows. You must install the prebuilt binary outside of your project directory and ensure its path is included in your system’s PATH environment variable.
Run `hugo env` to list the active transpilers.
If you build Hugo from source and run `mage test -v`, the test will fail if you install Dart Sass as a Snap package. This is due to the Snap package’s strict confinement model.
### Installing in a production environment
To use Dart Sass with Hugo on a [CI/CD](https://gohugo.io/quick-reference/glossary/#cicd)
platform, you typically must modify your build workflow to install Dart Sass before the Hugo site build begins. This is because these platforms don’t have Dart Sass pre-installed, and Hugo needs it to process your Sass files.
There’s one key exception where you can skip this step: you have committed your `resources` directory to your repository. This is only possible if:
* You have not changed Hugo’s default asset cache location.
* You have not set [`useResourceCacheWhen`](https://gohugo.io/configuration/build/#useresourcecachewhen)
to never in your project configuration.
By committing the `resources` directory, you’re providing the pre-built CSS files directly to your CI/CD platform, so it doesn’t need to run the Sass compilation itself.
For examples of how to install Dart Sass in a production environment, see these hosting guides:
* [Cloudflare](https://gohugo.io/host-and-deploy/host-on-cloudflare/)
* [GitHub Pages](https://gohugo.io/host-and-deploy/host-on-github-pages/)
* [GitLab Pages](https://gohugo.io/host-and-deploy/host-on-gitlab-pages/)
* [Netlify](https://gohugo.io/host-and-deploy/host-on-netlify/)
* [Render](https://gohugo.io/host-and-deploy/host-on-render/)
* [SourceHut](https://gohugo.io/host-and-deploy/host-on-sourcehut-pages/)
* [Vercel](https://gohugo.io/host-and-deploy/host-on-vercel/)
* * *
1. In 2023, the Sass team deprecated Embedded Dart Sass in favor of Dart Sass. [↩︎](https://gohugo.io/functions/css/sass/#fnref:1)
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/css/Sass.md)
---
# Global functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### page\
\
page\
\
Provides global access to a Page object.](https://gohugo.io/functions/global/page/)
[### site\
\
site\
\
Provides global access to the current Site object.](https://gohugo.io/functions/global/site/)
---
# Duration methods
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### Abs\
\
DURATION.Abs\
\
Returns the absolute value of the given time.Duration value.](https://gohugo.io/methods/duration/abs/)
[### Hours\
\
DURATION.Hours\
\
Returns the time.Duration value as a floating point number of hours.](https://gohugo.io/methods/duration/hours/)
[### Microseconds\
\
DURATION.Microseconds\
\
Returns the time.Duration value as an integer microsecond count.](https://gohugo.io/methods/duration/microseconds/)
[### Milliseconds\
\
DURATION.Milliseconds\
\
Returns the time.Duration value as an integer millisecond count.](https://gohugo.io/methods/duration/milliseconds/)
[### Minutes\
\
DURATION.Minutes\
\
Returns the time.Duration value as a floating point number of minutes.](https://gohugo.io/methods/duration/minutes/)
[### Nanoseconds\
\
DURATION.Nanoseconds\
\
Returns the time.Duration value as an integer nanosecond count.](https://gohugo.io/methods/duration/nanoseconds/)
[### Round\
\
DURATION1.Round DURATION2\
\
Returns the result of rounding DURATION1 to the nearest multiple of DURATION2.](https://gohugo.io/methods/duration/round/)
[### Seconds\
\
DURATION.Seconds\
\
Returns the time.Duration value as a floating point number of seconds.](https://gohugo.io/methods/duration/seconds/)
[### Truncate\
\
DURATION1.Truncate DURATION2\
\
Returns the result of rounding DURATION1 toward zero to a multiple of DURATION2.](https://gohugo.io/methods/duration/truncate/)
---
# collections.Apply
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice by transforming each element of the given slice using a specific function and parameters.
Syntax
collections.Apply SLICE FUNCTION PARAM...
Returns
\[\]any
Alias
apply
The `apply` function takes three or more arguments, depending on the function being applied to the slice elements.
The first argument is the slice itself, the second argument is the function name, and the remaining arguments are passed to the function, with the string `"."` representing the slice element.
{{ $s := slice "hello" "world" }}
{{ $s = apply $s "strings.FirstUpper" "." }}
{{ $s }} → [Hello World]
{{ $s = apply $s "strings.Replace" "." "l" "_" }}
{{ $s }} → [He__o Wor_d]
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Apply.md)
---
# collections.Append
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice by adding one or more elements, or an entire second slice, to the end of the given slice.
Syntax
collections.Append ELEMENT \[ELEMENT...\] SLICE
collections.Append SLICE1 SLICE2
Returns
\[\]any
Alias
append
This function appends all elements, excluding the last, to the last element. This allows [pipe](https://gohugo.io/quick-reference/glossary/#pipe)
constructs as shown below.
Append a single element to a slice:
{{ $s := slice "a" "b" }}
{{ $s }} → [a b]
{{ $s = $s | append "c" }}
{{ $s }} → [a b c]
Append two elements to a slice:
{{ $s := slice "a" "b" }}
{{ $s }} → [a b]
{{ $s = $s | append "c" "d" }}
{{ $s }} → [a b c d]
Append two elements, as a slice, to a slice. This produces the same result as the previous example:
{{ $s := slice "a" "b" }}
{{ $s }} → [a b]
{{ $s = $s | append (slice "c" "d") }}
{{ $s }} → [a b c d]
Start with an empty slice:
{{ $s := slice }}
{{ $s }} → []
{{ $s = $s | append "a" }}
{{ $s }} → [a]
{{ $s = $s | append "b" "c" }}
{{ $s }} → [a b c]
{{ $s = $s | append (slice "d" "e") }}
{{ $s }} → [a b c d e]
If you start with a slice of a slice:
{{ $s := slice (slice "a" "b") }}
{{ $s }} → [[a b]]
{{ $s = $s | append (slice "c" "d") }}
{{ $s }} → [[a b] [c d]]
To create a slice of slices, starting with an empty slice:
{{ $s := slice }}
{{ $s }} → []
{{ $s = $s | append (slice (slice "a" "b")) }}
{{ $s }} → [[a b]]
{{ $s = $s | append (slice "c" "d") }}
{{ $s }} → [[a b] [c d]]
Although the elements in the examples above are strings, you can use the `append` function with any data type, including Pages. For example, on the home page of a corporate site, to display links to the two most recent press releases followed by links to the four most recent articles:
{{ $p := where site.RegularPages "Type" "press-releases" | first 2 }}
{{ $p = $p | append (where site.RegularPages "Type" "articles" | first 4) }}
{{ with $p }}
{{ end }}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Append.md)
---
# Documentation
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Help us to improve the documentation by identifying issues and suggesting changes.
Introduction
------------
We welcome corrections and improvements to the documentation. The documentation lives in a separate repository from the main project. To contribute:
* For corrections and improvements to existing documentation, submit issues and pull requests to the [documentation repository](https://github.com/gohugoio/hugoDocs/)
.
* For documentation of new features, include the documentation changes in your pull request to the [project repository](https://github.com/gohugoio/hugo)
.
Guidelines
----------
### Style
Follow Google’s [developer documentation style guide](https://developers.google.com/style)
.
### Markdown
Adhere to these Markdown conventions:
* Use [ATX](https://spec.commonmark.org/current/#atx-headings)
headings (levels 2-4), not [setext](https://spec.commonmark.org/current/#setext-heading)
headings.
* Use [collapsed link references](https://discourse.gohugo.io/t/55714)
instead of full or shortcut references. For example:
This is a [link][].
[link]: https://example.org
* Use [fenced code blocks](https://spec.commonmark.org/current/#fenced-code-blocks)
instead of [indented code blocks](https://spec.commonmark.org/current/#indented-code-blocks)
.
* Use hyphens, not asterisks, for unordered [list items](https://spec.commonmark.org/current/#list-items)
.
* Use [callouts](https://gohugo.io/contribute/documentation/#callouts)
instead of bold text for emphasis.
* Do not mix [raw HTML](https://spec.commonmark.org/current/#raw-html)
within Markdown.
* Do not use bold text in place of a heading or description term (`dt`).
* Remove consecutive blank lines.
* Remove trailing spaces.
### Glossary
[Glossary](https://gohugo.io/quick-reference/glossary/)
terms are defined on individual pages, providing a central repository for definitions, though these pages are not directly linked from the site.
Definitions must be complete sentences, with the first sentence defining the term. Italicize the first occurrence of the term and any referenced glossary terms for consistency.
Link to glossary terms using this syntax: `[term](g)`
Term lookups are case-insensitive, ignore formatting, and support singular and plural forms. For example, all of these variations will link to the same glossary term:
[global resource](g)
[Global Resource](g)
[Global Resources](g)
[`Global Resources`](g)
Use the [glossary-term shortcode](https://gohugo.io/contribute/documentation/#glossary-term)
to insert a term definition:
{{% glossary-term "global resource" %}}
### Terminology
Link to the [glossary](https://gohugo.io/quick-reference/glossary/)
as needed and use terms consistently. Pay particular attention to:
* “front matter” (two words, except when referring to the configuration key)
* “home page” (two words)
* “website” (one word)
* “standalone” (one word, no hyphen)
* “map” (instead of “dictionary”)
* “flag” (instead of “option” for command-line flags)
* “client side” (noun), “client-side” (adjective)
* “server side” (noun), “server-side” (adjective)
* “Markdown” (capitalized)
* “open-source” (hyphenated adjective)
### Template types
When you refer to a template type, italicize it:
When creating a _taxonomy_ template, do this...
However, if the template type is also a link, do not italicize it to avoid distracting formatting:
When creating a [taxonomy] template, do this...
Do not italicize the template type in a title, heading, or front matter description.
### Titles and headings
* Use sentence-style capitalization.
* Avoid formatted strings.
* Keep them concise.
### Page descriptions
When writing the page `description` use imperative present tense when possible. For example:
---
description: Use these functions to read local or remote data files.
linkTitle: data
title: Data functions
---
+++
description = 'Use these functions to read local or remote data files.'
linkTitle = 'data'
title = 'Data functions'
+++
{
"description": "Use these functions to read local or remote data files.",
"linkTitle": "data",
"title": "Data functions"
}
### Writing style
Use active voice and present tense wherever possible.
No → With Hugo you can build a static site.
Yes → Build a static site with Hugo.
No → This will cause Hugo to generate HTML files in the `public` directory.
Yes → Hugo generates HTML files in the `public` directory.
Use second person instead of third person.
No → Users should exercise caution when deleting files.
Better → You must be cautious when deleting files.
Best → Be cautious when deleting files.
Minimize adverbs.
No → Hugo is extremely fast.
Yes → Hugo is fast.
“It’s an adverb, Sam. It’s a lazy tool of a weak mind.” (Outbreak, 1995).
### Function and method descriptions
Start descriptions in the functions and methods sections with “Returns”, or for boolean values, “Reports whether”.
### File paths and names
Enclose directory names, file names, and file paths in backticks, except when used in:
* Page titles
* Section headings (h1-h6)
* Definition list terms
* The `description` field in front matter
### Miscellaneous
Other best practices:
* Introduce lists with a sentence or phrase, not directly under a heading.
* Avoid bold text; use [callouts](https://gohugo.io/contribute/documentation/#callouts)
for emphasis.
* Do not put description terms (`dt`) in backticks unless syntactically necessary.
* Do not use Hugo’s `ref` or `relref` shortcodes.
* Prioritize current best practices over multiple options or historical information.
* Use short, focused code examples.
* Use [basic english](https://simple.wikipedia.org/wiki/Basic_English)
where possible for a global audience.
Front matter fields
-------------------
This site uses the front matter fields listed in the table below.
Of the four required fields, only `title` and `description` require data.
title: The title
description: The description
categories: []
keywords: []
This example demonstrates the minimum required front matter fields.
If quotation marks are required, prefer single quotes to double quotes when possible.
| Field | Description | Required |
| --- | --- | --- |
| `title` | The page title | ✔️ |
| `linkTitle` | A short version of the page title | |
| `description` | A complete sentence describing the page | ✔️ |
| `categories` | An array of terms in the categories taxonomy | ✔️ [1](https://gohugo.io/contribute/documentation/#fn:1) |
| `keywords` | An array of keywords used to identify related content | ✔️ [1](https://gohugo.io/contribute/documentation/#fn:1) |
| `publishDate` | Applicable to news items: the publication date | |
| `params.alt_title` | An alternate title: used in the “see also” panel if provided | |
| `params.functions_and_methods.aliases` | Applicable to function and method pages: an array of alias names | |
| `params.functions_and_methods.returnType` | Applicable to function and method pages: the data type returned | |
| `params.functions_and_methods.signatures` | Applicable to function and method pages: an array of signatures | |
| `params.hide_in_this_section` | Whether to hide the “in this section” panel | |
| `params.minversion` | Applicable to the quick start page: the minimum Hugo version required | |
| `params.permalink` | Reserved for use by the news content adapter | |
| `params.reference (used in glossary term)` | Applicable to glossary entries: a URL for additional information | |
| `params.searchable` | Whether to add the content of this page to the search index. The default value is cascaded down from the project configuration; `true` if the page kind is `page`, and `false` if the page kind is one of `home`, `section`, `taxonomy`, or `term`. Add this field to override the default value. | |
| `params.show_publish_date` | Whether to show the `publishDate` when rendering the page | |
| `weight` | The page weight | |
| `aliases` | Previous URLs used to access this page | |
| `expirydate` | The expiration date | |
Related content
---------------
When available, the “See also” sidebar displays related pages using Hugo’s [related content](https://gohugo.io/content-management/related-content/)
feature, based on front matter keywords. We ensure consistent keyword usage by validating them against `data/keywords.yaml` during the build process. If a keyword is not found, you’ll be alerted and must either modify the keyword or update the data file. This validation process helps to refine the related content for better results.
If the title in the “See also” sidebar is ambiguous or the same as another page, you can define an alternate title in the front matter:
linkTitle: Short title
params:
alt_title: Whatever you want
title: Long descriptive title
linkTitle = 'Short title'
title = 'Long descriptive title'
[params]
alt_title = 'Whatever you want'
{
"linkTitle": "Short title",
"params": {
"alt_title": "Whatever you want"
},
"title": "Long descriptive title"
}
Use of the alternate title is limited to the “See also” sidebar.
Think carefully before setting the `alt_title`. Use it only when absolutely necessary.
Code examples
-------------
With examples of template code:
* Indent with two spaces.
* Insert a space after an opening action delimiter.
* Insert a space before a closing action delimiter.
* Do not add white space removal syntax to action delimiters unless required. For example, inline elements like `img` and `a` require whitespace removal on both sides.
{{ if eq $foo $bar }}
{{ fmt.Printf "%s is %s" $foo $bar }}
{{ end }}
### Fenced code blocks
Always specify the language.
When providing a Mardown example, set the code language to “text” to prevent erroneous lexing/highlighting of shortcode calls.
```go-html-template
{{ if eq $foo "bar" }}
{{ print "foo is bar" }}
{{ end }}
```
To include a file name header and copy-to-clipboard button:
```go-html-template {file="layouts/_partials/foo.html" copy=true}
{{ if eq $foo "bar" }}
{{ print "foo is bar" }}
{{ end }}
```
To wrap the code block within an initially-opened `details` element using a non-default summary:
```go-html-template {details=true open=true summary="layouts/_partials/foo.html" copy=true}
{{ if eq $foo "bar" }}
{{ print "foo is bar" }}
{{ end }}
```
Whitespace trimming is enabled by default. To override this behavior and preserve leading and trailing spaces:
```go-html-template {trim=false}
{{ if eq $foo "bar" }}
{{ print "foo is bar" }}
{{ end }}
```
### Shortcode calls
Use this syntax :
```text
{{* foo */>}}
{{%/* foo */%}}
```
### Project configuration
Use the [code-toggle shortcode](https://gohugo.io/contribute/documentation/#code-toggle)
to include project configuration examples:
{{< code-toggle file=hugo >}}
baseURL = 'https://example.org/'
languageCode = 'en-US'
title = 'My Site'
{{< /code-toggle >}}
### Front matter
Use the [code-toggle shortcode](https://gohugo.io/contribute/documentation/#code-toggle)
to include front matter examples:
{{< code-toggle file=content/posts/my-first-post.md fm=true >}}
title = 'My first post'
date = 2023-11-09T12:56:07-08:00
draft = false
{{< /code-toggle >}}
Callouts
--------
To visually emphasize important information, use callouts (admonitions). Callout types are case-insensitive. Effective March 8, 2025, we utilize only three of the five available types.
* note (272 instances)
* warning (2 instances)
* caution (1 instance)
Limiting the number of callout types helps us to use them consistently.
> [!note]
> Useful information that users should know, even when skimming content.
Useful information that users should know, even when skimming content.
> [!warning]
> Urgent info that needs immediate user attention to avoid problems.
Urgent info that needs immediate user attention to avoid problems.
> [!caution]
> Advises about risks or negative outcomes of certain actions.
Advises about risks or negative outcomes of certain actions.
> [!tip]
> Helpful advice for doing things better or more easily.
Helpful advice for doing things better or more easily.
> [!important]
> Key information users need to know to achieve their goal.
Key information users need to know to achieve their goal.
Shortcodes
----------
These shortcodes are commonly used throughout the documentation. Other shortcodes are available for specialized use.
### code-toggle
Use the `code-toggle` shortcode to display examples of project configuration, front matter, or data files. This shortcode takes these arguments:
config
(`string`) The section of `hugo.Data.docs.config` to render.
copy
(`bool`) Whether to display a copy-to-clipboard button. Default is `false`.
datakey:
(`string`) The section of `hugo.Data.docs` to render.
file
(`string`) The file name to display above the rendered code. Omit the file extension for project configuration examples.
fm
(`bool`) Whether to render the code as front matter. Default is `false`.
skipHeader
(`bool`) Whether to omit top-level key(s) when rendering a section of `hugo.Data.docs.config`.
{{< code-toggle file=hugo copy=true >}}
baseURL = 'https://example.org/'
languageCode = 'en-US'
title = 'My Site'
{{< /code-toggle >}}
### deprecated-in
Use the `deprecated-in` shortcode to indicate that a feature is deprecated:
{{< deprecated-in 0.144.0 />}}
You can also include details:
{{< deprecated-in 0.144.0 >}}
Use [`hugo.IsServer`](/functions/hugo/isserver/) instead.
{{< /deprecated-in >}}
### eturl
Use the embedded template URL (`eturl`) shortcode to insert an absolute URL to the source code for an embedded template. The shortcode takes a single argument, the base file name of the template (omit the file extension).
This is a link to the [embedded alias template].
[embedded alias template]: <{{% eturl alias %}}>
### glossary-term
Use the `glossary-term` shortcode to insert the definition of the given glossary term.
{{% glossary-term scalar %}}
### include
Use the `include` shortcode to include content from another page.
{{% include "_common/glob-patterns.md" %}}
### new-in
Use the `new-in` shortcode to indicate a new feature:
{{< new-in 0.144.0 />}}
You can also include details:
{{< new-in 0.144.0 >}}
This is a new feature.
{{< /new-in >}}
New features
------------
Use the [new-in](https://gohugo.io/contribute/documentation/#new-in)
shortcode to indicate a new feature.
The new-in shortcode will trigger a build warning if the specified version is older than a predefined threshold, based on differences in major and minor versions. This serves as a reminder to remove this shortcode call. See [details](https://github.com/gohugoio/hugoDocs/blob/master/layouts/_partials/layouts/blocks/feature-state.html)
.
Deprecated features
-------------------
Use the [deprecated-in](https://gohugo.io/contribute/documentation/#deprecated-in)
shortcode to indicate that a feature is deprecated.
The deprecated-in shortcode will trigger a build warning if the specified version is older than a predefined threshold, based on differences in major and minor versions. This serves as a reminder to remove this shortcode call and the associated content. See [details](https://github.com/gohugoio/hugoDocs/blob/master/layouts/_partials/layouts/blocks/feature-state.html)
.
When deprecating a feature that has its own page, also set the `expiryDate` in front matter to two years from the date of deprecation. Include a brief comment to explain the setting:
expiryDate: 2028-03-03 # deprecated 2026-03-03 in v0.157.0
GitHub workflow
---------------
This section assumes that you have a working knowledge of Git and GitHub, and are comfortable working on the command line.
Use this workflow to create and submit pull requests.
Step 1
Fork the [documentation repository](https://github.com/gohugoio/hugoDocs/)
.
Step 2
Clone your fork.
Step 3
Create a new branch with a descriptive name that includes the corresponding issue number, if any:
git checkout -b restructure-foo-page-99999
Step 4
Make changes.
Step 5
Build the site locally to preview your changes.
Step 6
Commit your changes with a descriptive commit message:
* Provide a summary on the first line, typically 50 characters or less, followed by a blank line.
* Begin the summary with one of `content`, `theme`, `config`, `all`, or `misc`, followed by a colon, a space, and a brief description of the change beginning with a capital letter
* Use imperative present tense
* Optionally, provide a detailed description where each line is 72 characters or less, followed by a blank line.
* Optionally, add one or more “Fixes” or “Closes” keywords, each on its own line, referencing the [issues](https://github.com/gohugoio/hugoDocs/issues)
addressed by this change.
For example:
git commit -m "content: Restructure the taxonomy page
This restructures the taxonomy page by splitting topics into logical
sections, each with one or more examples.
Fixes #9999
Closes #9998"
Step 7
Push the new branch to your fork of the documentation repository.
Step 8
Visit the [documentation repository](https://github.com/gohugoio/hugoDocs/)
and create a pull request (PR).
Step 9
A project maintainer will review your PR and may request changes. You may delete your branch after the maintainer merges your PR.
* * *
1. The field is required, but its data is not. [↩︎](https://gohugo.io/contribute/documentation/#fnref:1)
[↩︎](https://gohugo.io/contribute/documentation/#fnref1:1)
* * *
Last updated: March 3, 2026 : [content: Update documentation contribution guide (63d4a992a)](https://github.com/gohugoio/hugoDocs/commit/63d4a992a25735a9cf38582d83c75dd6469b4ada)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/contribute/documentation.md)
---
# collections.Delimit
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a string by joining the values of the given slice or map with a delimiter.
Syntax
collections.Delimit SLICE|MAP DELIMITER \[LAST\]
Returns
string
Alias
delimit
Delimit a slice:
{{ $s := slice "b" "a" "c" }}
{{ delimit $s ", " }} → b, a, c
{{ delimit $s ", " " and "}} → b, a and c
Delimit a map:
The `delimit` function sorts maps by key, returning the values.
{{ $m := dict "b" 2 "a" 1 "c" 3 }}
{{ delimit $m ", " }} → 1, 2, 3
{{ delimit $m ", " " and "}} → 1, 2 and 3
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Delimit.md)
---
# collections.After
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice containing the elements after the first N elements of the given slice.
Syntax
collections.After N SLICE
Returns
\[\]any
Alias
after
The following shows `after` being used in conjunction with the [`slice`](https://gohugo.io/functions/collections/slice/)
function:
{{ $data := slice "one" "two" "three" "four" }}
{{ range after 2 $data }}
{{ . }}
{{ end }}
The template above is rendered to:
three
four
Example of `after` with `first`: 2nd–4th most recent articles
-------------------------------------------------------------
You can use `after` in combination with the [`first`](https://gohugo.io/functions/collections/first/)
function and Hugo’s [powerful sorting methods](https://gohugo.io/quick-reference/page-collections/#sort)
. Let’s assume you have a `section` page at `example.com/articles`. You have 10 articles, but you want your template to show only two rows:
1. The top row is titled “Featured” and shows only the most recently published article (i.e. by `publishdate` in the content files’ front matter).
2. The second row is titled “Recent Articles” and shows only the 2nd- to 4th-most recently published articles.
layouts/section/articles.html
{{ define "main" }}
{{ end }}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/After.md)
---
# collections.Complement
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice by identifying elements in the last given slice that do not appear in any of the preceding slices.
Syntax
collections.Complement SLICE \[SLICE...\]
Returns
\[\]any
Alias
complement
To find the elements within `$c3` that do not exist in `$c1` or `$c2`:
{{ $c1 := slice 3 }}
{{ $c2 := slice 4 5 }}
{{ $c3 := slice 1 2 3 4 5 }}
{{ complement $c1 $c2 $c3 }} → [1 2]
Make your code simpler to understand by using a [chained pipeline](https://pkg.go.dev/text/template#hdr-Pipelines)
:
{{ $c3 | complement $c1 $c2 }} → [1 2]
You can also use the `complement` function with page collections. Let’s say your site has five content types:
content/
├── blog/
├── books/
├── faqs/
├── films/
└── songs/
To list everything except blog articles (`blog`) and frequently asked questions (`faqs`):
{{ $blog := where site.RegularPages "Type" "blog" }}
{{ $faqs := where site.RegularPages "Type" "faqs" }}
{{ range site.RegularPages | complement $blog $faqs }}
{{ .LinkTitle }}
{{ end }}
Although the example above demonstrates the `complement` function, you could use the [`where`](https://gohugo.io/functions/collections/where/)
function as well:
{{ range where site.RegularPages "Type" "not in" (slice "blog" "faqs") }}
{{ .LinkTitle }}
{{ end }}
In this example we use the `complement` function to remove [stop words](https://en.wikipedia.org/wiki/Stop_word)
from a sentence:
{{ $text := "The quick brown fox jumps over the lazy dog" }}
{{ $stopWords := slice "a" "an" "in" "over" "the" "under" }}
{{ $filtered := split $text " " | complement $stopWords }}
{{ delimit $filtered " " }} → The quick brown fox jumps lazy dog
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Complement.md)
---
# collections.Dictionary
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a map created from the given key-value pairs.
Syntax
collections.Dictionary \[VALUE...\]
Returns
map\[string\]any
Alias
dict
Specify the key-value pairs as individual arguments:
{{ $m := dict "a" 1 "b" 2 }}
The above produces this data structure:
{
"a": 1,
"b": 2
}
To create an empty map:
{{ $m := dict }}
Note that the `key` can be either a `string` or a `[]string`. The latter is useful to create a deeply nested structure, e.g.:
{{ $m := dict (slice "a" "b" "c") "value" }}
The above produces this data structure:
{
"a": {
"b": {
"c": "value"
}
}
}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Dictionary.md)
---
# collections.First
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the first N elements of the given slice or string.
Syntax
collections.First N SLICE|STRING
Returns
any
Alias
first
{{ slice "a" "b" "c" | first 1 }} → [a]
{{ slice "a" "b" "c" | first 2 }} → [a b]
Given that a string is in effect a read-only slice of bytes, this function can be used to return the specified number of bytes from the beginning of the string:
{{ "abc" | first 1 }} → a
{{ "abc" | first 2 }} → ab
Note that a _character_ may consist of multiple _bytes_:
{{ "Schön" | first 3 }} → Sch
{{ "Schön" | first 4 }} → Sch\xc3
{{ "Schön" | first 5 }} → Schö
To use the `collections.First` function with a page collection:
{{ range first 5 .Pages }}
{{ .Render "summary" }}
{{ end }}
Set `N` to zero to return an empty slice:
{{ $emptyPageCollection := first 0 .Pages }}
Use `first` and [`where`](https://gohugo.io/functions/collections/where/)
together:
{{ range where .Pages "Section" "articles" | first 5 }}
{{ .Render "summary" }}
{{ end }}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/First.md)
---
# Deploy with rclone
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Deploy your site with the rclone CLI.
Assumptions
-----------
* A web host running a web server. This could be a shared hosting environment or a VPS.
* Access to your web host with any of the [protocols supported by rclone](https://rclone.org/#providers)
, such as SFTP.
* A functional static website built with Hugo
* Deploying from an [Rclone](https://rclone.org/)
compatible operating system
* You have [installed Rclone](https://rclone.org/install/)
.
**NB**: You can remove `--interactive` in the commands below once you are comfortable with rclone, if you wish. Also, `--gc` and `--minify` are optional in the commands below.
Getting started
---------------
The spoiler is that you can even deploy your entire website from any compatible OS with no configuration. Using SFTP for example:
hugo build --gc --minify
rclone sync --interactive --sftp-host sftp.example.com --sftp-user www-data --sftp-ask-password public/ :sftp:www/
Configure Rclone for even easier usage
--------------------------------------
The easiest way is simply to run `rclone config`.
The [Rclone docs](https://rclone.org/docs/)
provide [an example of configuring Rclone to use SFTP](https://rclone.org/sftp/)
.
For the next commands, we will assume you configured a remote you named `hugo-www`.
The above ‘spoiler’ commands could become:
hugo build --gc --minify
rclone sync --interactive public/ hugo-www:www/
After you issue the above commands (and respond to any prompts), check your website and you will see that it is deployed.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/host-and-deploy/deploy-with-rclone.md)
---
# Details shortcode
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Insert an HTML details element into your content using the details shortcode.
[New in v0.140.0](https://github.com/gohugoio/hugo/releases/tag/v0.140.0)
To override Hugo’s embedded `details` shortcode, copy the [source code](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_shortcodes/details.html)
to a file with the same name in the `layouts/_shortcodes` directory.
Example
-------
With this markup:
{{< details summary="See the details" >}}
This is a **bold** word.
{{< /details >}}
Hugo renders this HTML:
See the details
This is a bold word.
Which looks like this in your browser:
See the details
This is a **bold** word.
Arguments
---------
summary
(`string`) The content of the child `summary` element rendered from Markdown to HTML. Default is `Details`.
open
(`bool`) Whether to initially display the content of the `details` element. Default is `false`.
class
(`string`) The `class` attribute of the `details` element.
name
(`string`) The `name` attribute of the `details` element.
title
(`string`) The `title` attribute of the `details` element.
Styling
-------
Use CSS to style the `details` element, the `summary` element, and the content itself.
/* target the details element */
details { }
/* target the summary element */
details > summary { }
/* target the children of the summary element */
details > summary > * { }
/* target the content */
details > :not(summary) { }
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/shortcodes/details.md)
---
# Fmt functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### fmt.Errorf\
\
fmt.Errorf FORMAT \[INPUT\]\
\
Log an ERROR from a template.](https://gohugo.io/functions/fmt/errorf/)
[### fmt.Erroridf\
\
fmt.Erroridf ID FORMAT \[INPUT\]\
\
Log a suppressible ERROR from a template.](https://gohugo.io/functions/fmt/erroridf/)
[### fmt.Print\
\
fmt.Print INPUT\
\
Prints the default representation of the given arguments using the standard \`fmt.Print\` function.](https://gohugo.io/functions/fmt/print/)
[### fmt.Printf\
\
fmt.Printf FORMAT \[INPUT\]\
\
Formats a string using the standard \`fmt.Sprintf\` function.](https://gohugo.io/functions/fmt/printf/)
[### fmt.Println\
\
fmt.Println INPUT\
\
Prints the default representation of the given argument using the standard \`fmt.Print\` function and enforces a line break.](https://gohugo.io/functions/fmt/println/)
[### fmt.Warnf\
\
fmt.Warnf FORMAT \[INPUT\]\
\
Log a WARNING from a template.](https://gohugo.io/functions/fmt/warnf/)
[### fmt.Warnidf\
\
fmt.Warnidf ID FORMAT \[INPUT\]\
\
Log a suppressible WARNING from a template.](https://gohugo.io/functions/fmt/warnidf/)
---
# Hash functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### hash.FNV32a\
\
hash.FNV32a STRING\
\
Returns the 32-bit FNV (Fowler-Noll-Vo) non-cryptographic hash of the given string.](https://gohugo.io/functions/hash/fnv32a/)
[### hash.XxHash\
\
hash.XxHash STRING\
\
Returns the 64-bit xxHash non-cryptographic hash of the given string.](https://gohugo.io/functions/hash/xxhash/)
---
# collections.In
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports whether a value exists within the given slice or string.
Syntax
collections.In SLICE|STRING VALUE
Returns
bool
Alias
in
{{ $s := slice "a" "b" "c" }}
{{ in $s "b" }} → true
{{ $s := "abc" }}
{{ in $s "b" }} → true
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/In.md)
---
# fmt.Errorf
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Log an ERROR from a template.
Syntax
fmt.Errorf FORMAT \[INPUT\]
Returns
string
Alias
errorf
The documentation for Go’s [fmt](https://pkg.go.dev/fmt)
package describes the structure and content of the format string.
The `errorf` function evaluates the format string, then prints the result to the ERROR log and fails the build.
{{ errorf "The %q shortcode requires a src argument. See %s" .Name .Position }}
Use the [`erroridf`](https://gohugo.io/functions/fmt/erroridf/)
function to allow optional suppression of specific errors.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/fmt/Errorf.md)
---
# hash.FNV32a
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the 32-bit FNV (Fowler-Noll-Vo) non-cryptographic hash of the given string.
Syntax
hash.FNV32a STRING
Returns
int
{{ hash.FNV32a "Hello world" }} → 1498229191
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/hash/FNV32a.md)
---
# collections.Reverse
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice by reversing the order of elements in the given slice.
Syntax
collections.Reverse SLICE
Returns
\[\]any
{{ slice 2 1 3 | collections.Reverse }} → [3 1 2]
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Reverse.md)
---
# collections.Intersect
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice containing the common elements found in two given slices, in the same order as the first slice.
Syntax
collections.Intersect SLICE1 SLICE2
Returns
\[\]any
Alias
intersect
A useful example is to use it as `AND` filters when combined with where:
{{ $pages := where .Site.RegularPages "Type" "not in" (slice "page" "about") }}
{{ $pages := $pages | union (where .Site.RegularPages "Params.pinned" true) }}
{{ $pages := $pages | intersect (where .Site.RegularPages "Params.images" "!=" nil) }}
The above fetches regular pages not of `page` or `about` type unless they are pinned. And finally, we exclude all pages with no `images` set in Page parameters.
See [union](https://gohugo.io/functions/collections/union/)
for `OR`.
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Intersect.md)
---
# collections.Index
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns an element or value from the given slice or map at the specified key(s).
Syntax
collections.Index SLICE|MAP KEY...
Returns
any
Alias
index
Each indexed item must be a map or a slice:
{{ $s := slice "a" "b" "c" }}
{{ index $s 0 }} → a
{{ index $s 1 }} → b
{{ $m := dict "a" 100 "b" 200 }}
{{ index $m "b" }} → 200
Use two or more keys to access a nested value:
{{ $m := dict "a" 100 "b" 200 "c" (slice 10 20 30) }}
{{ index $m "c" 1 }} → 20
{{ $m := dict "a" 100 "b" 200 "c" (dict "d" 10 "e" 20) }}
{{ index $m "c" "e" }} → 20
You may also use a slice of keys to access a nested value:
{{ $m := dict "a" 100 "b" 200 "c" (dict "d" 10 "e" 20) }}
{{ $s := slice "c" "e" }}
{{ index $m $s }} → 20
Use the `collections.Index` function to access a nested value when the key is variable. For example, these are equivalent:
{{ .Site.Params.foo }}
{{ $k := "foo" }}
{{ index .Site.Params $k }}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/IndexFunction.md)
---
# collections.Slice
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice created from the given values.
Syntax
collections.Slice \[VALUE...\]
Returns
\[\]any
Alias
slice
{{ $s := slice "a" "b" "c" }}
{{ $s }} → [a b c]
To create an empty slice:
{{ $s := slice }}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Slice.md)
---
# Deploy with rsync
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Deploy your site with the rsync CLI.
Assumptions
-----------
* A web host running a web server. This could be a shared hosting environment or a VPS.
* Access to your web host with SSH
* A functional static website built with Hugo
The spoiler is that you can deploy your entire website with a command that looks like the following:
hugo && rsync -avz --delete public/ www-data@ftp.topologix.fr:~/www/
As you will see, we’ll put this command in a shell script file, which makes building and deployment as easy as executing `./deploy`.
Copy Your SSH Key to your host
------------------------------
To make logging in to your server more secure and less interactive, you can upload your SSH key. If you have already installed your SSH key to your server, you can move on to the next section.
First, install the ssh client. On Debian distributions, use the following command:
install-openssh.sh
sudo apt-get install openssh-client
Then generate your ssh key. First, create the `.ssh` directory in your home directory if it doesn’t exist:
~$ cd && mkdir .ssh & cd .ssh
Next, execute this command to generate a new keypair called `rsa_id`:
~/.ssh/$ ssh-keygen -t rsa -q -C "For SSH" -f rsa_id
You’ll be prompted for a passphrase, which is an extra layer of protection. Enter the passphrase you’d like to use, and then enter it again when prompted, or leave it blank if you don’t want to have a passphrase. Not using a passphrase will let you transfer files non-interactively, as you won’t be prompted for a password when you log in, but it is slightly less secure.
To make logging in easier, add a definition for your web host to the file `~/.ssh/config` with the following command, replacing `HOST` with the IP address or hostname of your web host, and `USER` with the username you use to log in to your web host when transferring files:
~/.ssh/$ cat >> config <
Hugo renders this to:
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/fmt/Printf.md)
---
# fmt.Print
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Prints the default representation of the given arguments using the standard `fmt.Print` function.
Syntax
fmt.Print INPUT
Returns
string
Alias
print
{{ print "foo" }} → foo
{{ print "foo" "bar" }} → foobar
{{ print (slice 1 2 3) }} → [1 2 3]
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/fmt/Print.md)
---
# fmt.Println
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Prints the default representation of the given argument using the standard `fmt.Print` function and enforces a line break.
Syntax
fmt.Println INPUT
Returns
string
Alias
println
{{ println "foo" }} → foo\n
{{ println "foo" "bar" }} → foo bar\n
* * *
Last updated: December 19, 2025 : [Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' (7e1a08e54)](https://github.com/gohugoio/hugoDocs/commit/7e1a08e545030efcad0ac52c1cf9469244bc3f2b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/fmt/Println.md)
---
# hash.XxHash
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the 64-bit xxHash non-cryptographic hash of the given string.
Syntax
hash.XxHash STRING
Returns
string
Alias
xxhash
{{ hash.XxHash "Hello world" }} → c500b0c912b376d8
[xxHash](https://xxhash.com/)
is a very fast non-cryptographic hash algorithm. Hugo uses [this Go implementation](https://github.com/cespare/xxhash)
.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/hash/XxHash.md)
---
# Configure file caches
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Configure file caches.
This is the default configuration:
caches:
assets:
dir: :resourceDir/_gen
maxAge: -1
getresource:
dir: :cacheDir/:project
maxAge: -1
images:
dir: :resourceDir/_gen
maxAge: -1
misc:
dir: :cacheDir/:project
maxAge: -1
modulegitinfo:
dir: :cacheDir/modules
maxAge: 24h
modulequeries:
dir: :cacheDir/modules
maxAge: 24h
modules:
dir: :cacheDir/modules
maxAge: -1
[caches]
[caches.assets]
dir = ':resourceDir/_gen'
maxAge = -1
[caches.getresource]
dir = ':cacheDir/:project'
maxAge = -1
[caches.images]
dir = ':resourceDir/_gen'
maxAge = -1
[caches.misc]
dir = ':cacheDir/:project'
maxAge = -1
[caches.modulegitinfo]
dir = ':cacheDir/modules'
maxAge = '24h'
[caches.modulequeries]
dir = ':cacheDir/modules'
maxAge = '24h'
[caches.modules]
dir = ':cacheDir/modules'
maxAge = -1
{
"caches": {
"assets": {
"dir": ":resourceDir/_gen",
"maxAge": -1
},
"getresource": {
"dir": ":cacheDir/:project",
"maxAge": -1
},
"images": {
"dir": ":resourceDir/_gen",
"maxAge": -1
},
"misc": {
"dir": ":cacheDir/:project",
"maxAge": -1
},
"modulegitinfo": {
"dir": ":cacheDir/modules",
"maxAge": "24h"
},
"modulequeries": {
"dir": ":cacheDir/modules",
"maxAge": "24h"
},
"modules": {
"dir": ":cacheDir/modules",
"maxAge": -1
}
}
}
Purpose
-------
Hugo uses file caches to store data on disk, avoiding repeated operations within the same build and persisting data from one build to the next.
assets
Caches processed CSS and Sass resources.
getresource
Caches files fetched from remote URLs via the [`resources.GetRemote`](https://gohugo.io/functions/resources/getremote/)
function.
images
Caches processed images.
misc
Caches miscellaneous data.
modulegitinfo
Caches Git information for modules.
modulequeries
Caches the results of module resolution queries.
modules
Caches downloaded modules.
Keys
----
dir
(`string`) The absolute file system path where Hugo stores the cached files. You can begin the path with the `:cacheDir` or `:resourceDir` [tokens](https://gohugo.io/configuration/caches/#tokens)
to anchor the cache to specific system or project locations.
maxAge
(`string`) The duration a cached entry remains valid before being evicted, expressed as a [duration](https://gohugo.io/quick-reference/glossary/#duration)
. A value of `0` disables the cache for that key, and a value of `-1` means the cache entry never expires. Default is `-1`.
Tokens
------
`:cacheDir`
(`string`) The designated cache directory. See [details](https://gohugo.io/configuration/all/#cachedir)
.
`:project`
(`string`) The base directory name of the current Hugo project. This ensures isolated file caches for each project, preventing the `hugo build --gc` command from affecting other projects on the same machine.
`:resourceDir`
(`string`) The designated directory for caching output from [asset pipelines](https://gohugo.io/quick-reference/glossary/#asset-pipeline)
. See [details](https://gohugo.io/configuration/all/#resourcedir)
.
Garbage collection
------------------
As you modify your site or change your configuration, cached files from previous builds may remain on disk, consuming unnecessary space. Use the `hugo build --gc` command to remove these expired or unused entries from the file cache.
* * *
Last updated: February 27, 2026 : [content: Miscellaneous udpates for v0.157.0 (35da1aa3c)](https://github.com/gohugoio/hugoDocs/commit/35da1aa3c2fe3b54bdb57df1a308533844af9df5)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/configuration/caches.md)
---
# collections.D
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a sorted slice of unique random integers based on a given seed, count, and maximum value.
Syntax
collections.D SEED N HIGH
Returns
\[\]int
[New in v0.149.0](https://github.com/gohugoio/hugo/releases/tag/v0.149.0)
The `collections.D` function returns a sorted slice of unique random integers in the half-open [interval](https://gohugo.io/quick-reference/glossary/#interval)
`[0, HIGH)` using the provided [`SEED`](https://gohugo.io/quick-reference/glossary/#seed)\
value. The number of elements in the resulting slice is `N` or `HIGH`, whichever is less.\
\
* `N` and `H` must be integers in the closed interval `[0, 1000000]`\
* `SEED` must be an integer in the closed interval `[0, 2^64 - 1]`\
\
Return values\
-------------\
\
| Condition | Return value | |\
| --- | --- | --- |\
| `N <= HIGH` | A sorted random sample of size `N` using J. S. Vitter’s [Method D](https://getkerf.wordpress.com/2016/03/30/the-best-algorithm-no-one-knows-about/) for sequential random sampling | |\
| `N > HIGH` | The full, sorted range `[0, HIGH)` of size `HIGH` | |\
| `N == 0` | An empty slice | |\
| `N < 0` | Error | |\
| `N > 10^6` | Error | |\
| `HIGH == 0` | An empty slice | |\
| `HIGH < 0` | Error | |\
| `HIGH > 10^6` | Error | |\
| `SEED < 0` | Error | |\
\
Examples\
--------\
\
{{ collections.D 6 7 42 }} → [4, 9, 10, 20, 22, 24, 41]\
\
The example above generates the _same_ random numbers each time it is called. To generate a _different_ set of 7 random numbers in the same range, change the seed value.\
\
{{ collections.D 2 7 42 }} → [3, 11, 19, 25, 32, 33, 38]\
\
When `N` is greater than `HIGH`, this function returns the full, sorted range \[0, `HIGH`) of size `HIGH`:\
\
{{ collections.D 6 42 7 }} → [0 1 2 3 4 5 6]\
\
A common use case is the selection of random pages from a page collection. For example, to render a list of 5 random pages using the [day of the year](https://gohugo.io/methods/time/yearday/)\
as the seed value:\
\
\
\
The construct above is significantly faster than using the [`collections.Shuffle`](https://gohugo.io/functions/collections/shuffle/)\
function.\
\
Seed value\
----------\
\
Choosing an appropriate seed value depends on your objective.\
\
| Objective | Seed example |\
| --- | --- |\
| Consistent result | `42` |\
| Different result on each call | `int time.Now.UnixNano` |\
| Same result per day | `time.Now.YearDay` |\
| Same result per page | `hash.FNV32a .Path` |\
| Different result per page per day | `hash.FNV32a (print .Path time.Now.YearDay)` |\
\
* * *\
\
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)\
\
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/D.md)
---
# collections.Group
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a map by grouping the given page collection (slice) by a specific key.
Syntax
collections.Group KEY PAGES
Returns
page.PageGroup
Alias
group
{{ $new := .Site.RegularPages | first 10 | group "New" }}
{{ $old := .Site.RegularPages | last 10 | group "Old" }}
{{ $groups := slice $new $old }}
{{ range $groups }}
{{ end }}
The page group you get from `group` is of the same type you get from the built-in [group methods](https://gohugo.io/quick-reference/page-collections/#group)
in Hugo. The example above can be [paginated](https://gohugo.io/templates/pagination/)
.
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Group.md)
---
# collections.IsSet
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports whether a specific key or index exists in the given map or slice.
Syntax
collections.IsSet MAP|SLICE KEY|INDEX
Returns
bool
Alias
isset
For example, consider this project configuration:
params:
showHeroImage: false
[params]
showHeroImage = false
{
"params": {
"showHeroImage": false
}
}
If the value of `showHeroImage` is `true`, we can detect that it exists using either `if` or `with`:
{{ if site.Params.showHeroImage }}
{{ site.Params.showHeroImage }} → true
{{ end }}
{{ with site.Params.showHeroImage }}
{{ . }} → true
{{ end }}
But if the value of `showHeroImage` is `false`, we can’t use either `if` or `with` to detect its existence. In this case, you must use the `isset` function:
{{ if isset site.Params "showheroimage" }}
The showHeroImage parameter is set to {{ site.Params.showHeroImage }}.
{{ end }}
When using the `isset` function you must reference the key using lower case. See the previous example.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/IsSet.md)
---
# collections.Merge
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a map by combining two or more given maps.
Syntax
collections.Merge MAP MAP...
Returns
map\[string\]any
Alias
merge
Returns the result of merging two or more maps from left to right. If a key already exists, `merge` updates its value. If a key is absent, `merge` inserts the value under the new key.
Key handling is case-insensitive.
The following examples use these map definitions:
{{ $m1 := dict "x" "foo" }}
{{ $m2 := dict "x" "bar" "y" "wibble" }}
{{ $m3 := dict "x" "baz" "y" "wobble" "z" (dict "a" "huey") }}
Example 1
{{ $merged := merge $m1 $m2 $m3 }}
{{ $merged.x }} → baz
{{ $merged.y }} → wobble
{{ $merged.z.a }} → huey
Example 2
{{ $merged := merge $m3 $m2 $m1 }}
{{ $merged.x }} → foo
{{ $merged.y }} → wibble
{{ $merged.z.a }} → huey
Example 3
{{ $merged := merge $m2 $m3 $m1 }}
{{ $merged.x }} → foo
{{ $merged.y }} → wobble
{{ $merged.z.a }} → huey
Example 4
{{ $merged := merge $m1 $m3 $m2 }}
{{ $merged.x }} → bar
{{ $merged.y }} → wibble
{{ $merged.z.a }} → huey
Regardless of depth, merging only applies to maps. For slices, use [append](https://gohugo.io/functions/collections/append/)
.
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Merge.md)
---
# collections.Seq
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice of integers starting from 1 or a given value, incrementing by 1 or a given value, and ending at a given value.
Syntax
collections.Seq LAST
collections.Seq FIRST LAST
collections.Seq FIRST INCREMENT LAST
Returns
\[\]int
Alias
seq
{{ seq 2 }} → [1 2]
{{ seq 0 2 }} → [0 1 2]
{{ seq -2 2 }} → [-2 -1 0 1 2]
{{ seq -2 2 2 }} → [-2 0 2]
A contrived example of iterating over a sequence of integers:
{{ $product := 1 }}
{{ range seq 4 }}
{{ $product = mul $product . }}
{{ end }}
{{ $product }} → 24
The slice created by this function is limited to 1 million elements.
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Seq.md)
---
# collections.Last
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the last N elements of the given slice or string.
Syntax
collections.Last N SLICE|STRING
Returns
any
Alias
last
{{ slice "a" "b" "c" | last 1 }} → [c]
{{ slice "a" "b" "c" | last 2 }} → [b c]
Given that a string is in effect a read-only slice of bytes, this function can be used to return the specified number of bytes from the end of the string:
{{ "abc" | last 1 }} → c
{{ "abc" | last 2 }} → bc
Note that a _character_ may consist of multiple _bytes_:
{{ "Schön" | last 1 }} → n
{{ "Schön" | last 2 }} → \xb6n
{{ "Schön" | last 3 }} → ön
To use the `collections.Last` function with a page collection:
{{ range last 5 .Pages }}
{{ .Render "summary" }}
{{ end }}
Set `N` to zero to return an empty slice:
{{ $emptyPageCollection := last 0 .Pages }}
Use `last` and [`where`](https://gohugo.io/functions/collections/where/)
together:
{{ range where .Pages "Section" "articles" | last 5 }}
{{ .Render "summary" }}
{{ end }}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Last.md)
---
# collections.SymDiff
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice containing the symmetric difference of two given slices.
Syntax
SLICE1 | collections.SymDiff SLICE2
Returns
\[\]any
Alias
symdiff
Example:
{{ slice 1 2 3 | symdiff (slice 3 4) }} → [1 2 4]
Also see [https://en.wikipedia.org/wiki/Symmetric\_difference](https://en.wikipedia.org/wiki/Symmetric_difference)
.
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/SymDiff.md)
---
# collections.Querify
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a URL query string from the given map, slice, or sequence of key-value pairs.
Syntax
collections.Querify MAP|SLICE|KEY VALUE...
Returns
string
Alias
querify
Specify the key-value pairs as a map, a slice, or a sequence of scalar values. For example, the following are equivalent:
{{ collections.Querify (dict "a" 1 "b" 2) }}
{{ collections.Querify (slice "a" 1 "b" 2) }}
{{ collections.Querify "a" 1 "b" 2 }}
To append a query string to a URL:
{{ $qs := collections.Querify (dict "a" 1 "b" 2) }}
{{ $href := printf "https://example.org?%s" $qs }}
Link
Hugo renders this to:
Link
You can also pass in a map from your project configuration or front matter. For example:
---
params:
query:
a: 1
b: 2
title: Example
---
+++
title = 'Example'
[params]
[params.query]
a = 1
b = 2
+++
{
"params": {
"query": {
"a": 1,
"b": 2
}
},
"title": "Example"
}
{{ collections.Querify .Params.query }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Querify.md)
---
# Content
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the content of the given resource.
Syntax
RESOURCE.Content
Returns
any
Use this method with [global resources](https://gohugo.io/quick-reference/glossary/#global-resource)
, [page resources](https://gohugo.io/quick-reference/glossary/#page-resource)
, or [remote resources](https://gohugo.io/quick-reference/glossary/#remote-resource)
.
The `Content` method on a `Resource` object returns `template.HTML` when the [resource type](https://gohugo.io/methods/resource/resourcetype/)
is `page`, otherwise it returns a `string`.
assets/quotations/kipling.txt
He travels the fastest who travels alone.
To get the content:
{{ with resources.Get "quotations/kipling.txt" }}
{{ .Content }} → He travels the fastest who travels alone.
{{ end }}
To get the size in bytes:
{{ with resources.Get "quotations/kipling.txt" }}
{{ .Content | len }} → 42
{{ end }}
To create an inline image:
{{ with resources.Get "images/a.jpg" }}
{{ end }}
To create inline CSS:
{{ with resources.Get "css/style.css" }}
{{ end }}
To create inline JavaScript:
{{ with resources.Get "js/script.js" }}
{{ end }}
* * *
Last updated: August 23, 2025 : [Merge commit 'bfa74537929f409fca841540b971125b7678963a' (6c911d1e5)](https://github.com/gohugoio/hugoDocs/commit/6c911d1e52fb9c8065c079820327f4b0e37529d4)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/resource/Content.md)
---
# Fingerprint
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Cryptographically hash the content of the given resource.
See the [`resources.Fingerprint`](https://gohugo.io/functions/resources/fingerprint/)
function.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/hugo-pipes/fingerprint.md)
---
# fmt.Warnf
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Log a WARNING from a template.
Syntax
fmt.Warnf FORMAT \[INPUT\]
Returns
string
Alias
warnf
The documentation for Go’s [fmt](https://pkg.go.dev/fmt)
package describes the structure and content of the format string.
The `warnf` function evaluates the format string, then prints the result to the WARNING log. Hugo prints each unique message once to avoid flooding the log with duplicate warnings.
{{ warnf "The %q shortcode was unable to find %s. See %s" .Name $file .Position }}
Use the [`warnidf`](https://gohugo.io/functions/fmt/warnidf/)
function to allow optional suppression of specific warnings.
To prevent suppression of duplicate messages when using `warnf` for debugging, make each message unique with the [`math.Counter`](https://gohugo.io/functions/math/counter/)
function. For example:
{{ range site.RegularPages }}
{{ .Section | warnf "%#[2]v [%[1]d]" math.Counter }}
{{ end }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/fmt/Warnf.md)
---
# fmt.Warnidf
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Log a suppressible WARNING from a template.
Syntax
fmt.Warnidf ID FORMAT \[INPUT\]
Returns
string
Alias
warnidf
The documentation for Go’s [fmt](https://pkg.go.dev/fmt)
package describes the structure and content of the format string.
The `warnidf` function evaluates the format string, then prints the result to the WARNING log. Unlike the [`warnf`](https://gohugo.io/functions/fmt/warnf/)
function, you may suppress warnings logged by the `warnidf` function by adding the message ID to the `ignoreLogs` array in your project configuration.
This template code:
{{ warnidf "warning-42" "You should consider fixing this." }}
Produces this console log:
WARN You should consider fixing this.
You can suppress this warning by adding the following to your project configuration:
ignoreLogs = ['warning-42']
To suppress this message:
ignoreLogs:
- warning-42
ignoreLogs = ['warning-42']
{
"ignoreLogs": [\
"warning-42"\
]
}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/fmt/Warnidf.md)
---
# Glob patterns
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

A quick reference guide to glob pattern syntax and matching rules for wildcards, character sets, and delimiters, featuring illustrative examples.
A _glob pattern_ is a pattern used to match sets of values. It is a shorthand for specifying multiple targets at once, making it easier to work with groups of data or configurations.
The table below details the supported glob pattern syntax and its matching behavior. Each example illustrates a specific match type, the pattern used, and the expected boolean result when evaluated against a test string.
| Match type | Glob pattern | Test string | Match? |
| --- | --- | --- | --- |
| Simple wildcard | `a/*.md` | `a/page.md` | true |
| Literal match | `'a/*.md'` | `a/*.md` | true |
| Single-level wildcard | `a/*/page.md` | `a/b/page.md` | true |
| Single-level wildcard | `a/*/page.md` | `a/b/c/page.md` | false |
| Multi-level wildcard | `a/**/page.md` | `a/b/c/page.md` | true |
| Single character | `file.???` | `file.txt` | true |
| Single character | `file.???` | `file.js` | false |
| Delimiter exclusion | `?at` | `f/at` | false |
| Character list | `f.[jt]xt` | `f.txt` | true |
| Negated list | `f.[!j]xt` | `f.txt` | true |
| Character range | `f.[a-c].txt` | `f.b.txt` | true |
| Character range | `f.[a-c].txt` | `f.z.txt` | false |
| Negated range | `f.[!a-c].txt` | `f.z.txt` | true |
| Pattern alternates | `*.{jpg,png}` | `logo.png` | true |
| No match | `*.{jpg,png}` | `logo.webp` | false |
The matching logic follows these rules:
* Standard wildcard (`*`) matches any character except for a delimiter.
* Super wildcard (`**`) matches any character including delimiters.
* Single character (`?`) matches exactly one character, excluding delimiters.
* Negation (`!`) matches any character except those specified in a list or range when used inside brackets.
* Character ranges (`[a-z]`) match any single character within the specified range.
The delimiter is a slash (`/`), except when matching semantic version strings, where the delimiter is a dot (`.`).
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/quick-reference/glob-patterns.md)
---
# Comments
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Hugo ships with an internal Disqus template, but this isn’t the only commenting system that will work with your new Hugo website.
Hugo ships with support for [Disqus](https://disqus.com/)
, a third-party service that provides comment and community capabilities to websites via JavaScript.
Your theme may already support Disqus, but if not, it is easy to add to your templates via [Hugo’s built-in Disqus partial](https://gohugo.io/templates/embedded/#disqus)
.
Add Disqus
----------
Hugo comes with all the code you need to load Disqus into your templates. Before adding Disqus to your site, you’ll need to [set up an account](https://disqus.com/profile/signup/)
.
### Configure Disqus
Disqus comments require you set a single value in your [project configuration](https://gohugo.io/configuration/)
:
services:
disqus:
shortname: your-disqus-shortname
[services]
[services.disqus]
shortname = 'your-disqus-shortname'
{
"services": {
"disqus": {
"shortname": "your-disqus-shortname"
}
}
}
For many websites, this is enough configuration. However, you also have the option to set the following in the [front matter](https://gohugo.io/content-management/front-matter/)
of a single content file:
* `disqus_identifier`
* `disqus_title`
* `disqus_url`
### Render Hugo’s built-in Disqus partial template
Disqus has its own [internal template](https://gohugo.io/templates/embedded/#disqus)
available, to render it add the following code where you want comments to appear:
{{ partial "disqus.html" . }}
Alternatives
------------
Commercial commenting systems:
* [Commentix](https://www.commentix.com/)
* [Emote](https://emote.com/)
* [Graph Comment](https://graphcomment.com/)
* [Hyvor Talk](https://talk.hyvor.com/)
* [IntenseDebate](https://intensedebate.com/)
* [ReplyBox](https://getreplybox.com/)
Open-source commenting systems:
* [Cactus Comments](https://cactus.chat/docs/integrations/hugo/)
* [Comentario](https://gitlab.com/comentario/comentario/)
* [Comma](https://github.com/Dieterbe/comma/)
* [Commento](https://commento.io/)
* [Discourse](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963)
* [Giscus](https://giscus.app/)
* [Isso](https://isso-comments.de/)
* [Remark42](https://remark42.com/)
* [Staticman](https://staticman.net/)
* [Talkyard](https://blog-comments.talkyard.io/)
* [Utterances](https://utteranc.es/)
* [Zoomment](https://zoomment.com/)
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/content-management/comments.md)
---
# Configure cascade
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Configure cascade.
You can configure your site to cascade front matter values to the home page and any of its descendants. However, this cascading will be prevented if the descendant already defines the field, or if a closer ancestor [node](https://gohugo.io/quick-reference/glossary/#node)
has already cascaded a value for the same field through its front matter’s `cascade` key.
You can also configure cascading behavior within a page’s front matter. See [details](https://gohugo.io/content-management/front-matter/#cascade-1)
.
For example, to cascade a “color” parameter to the home page and all its descendants:
cascade:
params:
color: red
[cascade]
[cascade.params]
color = 'red'
{
"cascade": {
"params": {
"color": "red"
}
}
}
Target
------
The `target`[1](https://gohugo.io/configuration/cascade/#fn:1)
keyword allows you to target specific pages or [environments](https://gohugo.io/quick-reference/glossary/#environment)
. For example, to cascade a “color” parameter to pages within the “articles” section, including the “articles” section page itself:
cascade:
params:
color: red
target:
path: '{/articles,/articles/**}'
[cascade]
[cascade.params]
color = 'red'
[cascade.target]
path = '{/articles,/articles/**}'
{
"cascade": {
"params": {
"color": "red"
},
"target": {
"path": "{/articles,/articles/**}"
}
}
}
Use any combination of these keywords to target pages and/or environments:
environment
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching the build [environment](https://gohugo.io/quick-reference/glossary/#environment)
. For example: `{staging,production}`.
kind
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching the [page kind](https://gohugo.io/quick-reference/glossary/#page-kind)
. For example: `{taxonomy,term}`.
lang
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching the [page language](https://gohugo.io/methods/page/language/)
. For example: `{en,de}`.
path
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching the page’s [logical path](https://gohugo.io/quick-reference/glossary/#logical-path)
. For example: `{/books,/books/**}`.
Array
-----
Define an array of cascade parameters to apply different values to different targets. For example:
cascade:
- params:
color: red
target:
kind: page
lang: '{en,de}'
path: /books/**
- params:
color: blue
target:
environment: production
kind: page
path: /films/**
[[cascade]]
[cascade.params]
color = 'red'
[cascade.target]
kind = 'page'
lang = '{en,de}'
path = '/books/**'
[[cascade]]
[cascade.params]
color = 'blue'
[cascade.target]
environment = 'production'
kind = 'page'
path = '/films/**'
{
"cascade": [\
{\
"params": {\
"color": "red"\
},\
"target": {\
"kind": "page",\
"lang": "{en,de}",\
"path": "/books/**"\
}\
},\
{\
"params": {\
"color": "blue"\
},\
"target": {\
"environment": "production",\
"kind": "page",\
"path": "/films/**"\
}\
}\
]
}
* * *
1. The `_target` alias for `target` is deprecated and will be removed in a future release. [↩︎](https://gohugo.io/configuration/cascade/#fnref:1)
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/configuration/cascade.md)
---
# collections.Shuffle
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice by randomizing the element order of the given slice.
Syntax
collections.Shuffle SLICE
Returns
\[\]any
Alias
shuffle
{{ collections.Shuffle (slice "a" "b" "c") }} → [b a c]
The result will vary from one build to the next.
To render an unordered list of 5 random pages from a page collection:
{{ $p := site.RegularPages }}
{{ range $p | collections.Shuffle | first 5 }}
[New in v0.149.0](https://github.com/gohugoio/hugo/releases/tag/v0.149.0)
Using the [`collections.D`](https://gohugo.io/functions/collections/d/)
function for the same task is significantly faster.
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Shuffle.md)
---
# collections.Uniq
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice by removing duplicate elements from the given slice.
Syntax
collections.Uniq SLICE
Returns
\[\]any
Alias
uniq
{{ slice 1 3 2 1 | uniq }} → [1 3 2]
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Uniq.md)
---
# collections.KeyVals
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a KeyVals struct by pairing a given key and values.
Syntax
collections.KeyVals KEY VALUE...
Returns
types.KeyValues
Alias
keyVals
The primary application for this function is the definition of the `namedSlices` value in the options map passed to the [`Related`](https://gohugo.io/methods/pages/related/)
method on the `Pages` object.
See [related content](https://gohugo.io/content-management/related-content/)
.
{{ $kv := keyVals "foo" "a" "b" "c" }}
The resulting data structure is:
{
"Key": "foo",
"Values": [\
"a",\
"b",\
"c"\
]
}
To extract the key and values:
{{ $kv.Key }} → foo
{{ $kv.Values }} → [a b c]
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/KeyVals.md)
---
# collections.Union
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice containing the unique elements from two given slices.
Syntax
collections.Union SLICE1 SLICE2
Returns
\[\]any
Alias
union
{{ union (slice 1 2 3) (slice 3 4 5) }} → [1 2 3 4 5]
{{ union (slice 1 2 3) nil }} → [1 2 3]
{{ union nil (slice 1 2 3) }} → [1 2 3]
{{ union nil nil }} → []
OR filter in where query
------------------------
This is also very useful to use as `OR` filters when combined with where:
{{ $pages := where .Site.RegularPages "Type" "not in" (slice "page" "about") }}
{{ $pages = $pages | union (where .Site.RegularPages "Params.pinned" true) }}
{{ $pages = $pages | intersect (where .Site.RegularPages "Params.images" "!=" nil) }}
The above fetches regular pages not of `page` or `about` type unless they are pinned. And finally, we exclude all pages with no `images` set in Page parameters.
See [intersect](https://gohugo.io/functions/collections/intersect/)
for `AND`.
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Union.md)
---
# Figure shortcode
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Insert an HTML figure element into your content using the figure shortcode.
To override Hugo’s embedded `figure` shortcode, copy the [source code](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_shortcodes/figure.html)
to a file with the same name in the `layouts/_shortcodes` directory.
Example
-------
With this markup:
{{< figure
src="/images/examples/zion-national-park.jpg"
alt="A photograph of Zion National Park"
link="https://www.nps.gov/zion/index.htm"
caption="Zion National Park"
class="ma0 w-75"
>}}
Hugo renders this HTML:
Zion National Park
Which looks like this in your browser:
[](https://www.nps.gov/zion/index.htm)
Zion National Park
Arguments
---------
src
(`string`) The `src` attribute of the `img` element. Typically this is a [page resource](https://gohugo.io/quick-reference/glossary/#page-resource)
or a [global resource](https://gohugo.io/quick-reference/glossary/#global-resource)
.
alt
(`string`) The `alt` attribute of the `img` element.
width
(`int`) The `width` attribute of the `img` element.
height
(`int`) The `height` attribute of the `img` element.
loading
(`string`) The `loading` attribute of the `img` element.
class
(`string`) The `class` attribute of the `figure` element.
link
(`string`) The `href` attribute of the anchor element that wraps the `img` element.
target
(`string`) The `target` attribute of the anchor element that wraps the `img` element.
rel
(`rel`) The `rel` attribute of the anchor element that wraps the `img` element.
title
(`string`) Within the `figurecaption` element, the title is at the top, wrapped within an `h4` element.
caption
(`string`) Within the `figurecaption` element, the caption is at the bottom and may contain plain text or markdown.
attr
(`string`) Within the `figurecaption` element, the attribution appears next to the caption and may contain plain text or markdown.
attrlink
(`string`) The `href` attribute of the anchor element that wraps the attribution.
Image location
--------------
The `figure` shortcode resolves internal Markdown destinations by looking for a matching [page resource](https://gohugo.io/quick-reference/glossary/#page-resource)
, falling back to a matching [global resource](https://gohugo.io/quick-reference/glossary/#global-resource)
. Remote destinations are passed through, and the render hook will not throw an error or warning if unable to resolve a destination.
You must place global resources in the `assets` directory. If you have placed your resources in the `static` directory, and you are unable or unwilling to move them, you must mount the `static` directory to the `assets` directory by including both of these entries in your project configuration:
module:
mounts:
- source: assets
target: assets
- source: static
target: assets
[module]
[[module.mounts]]
source = 'assets'
target = 'assets'
[[module.mounts]]
source = 'static'
target = 'assets'
{
"module": {
"mounts": [\
{\
"source": "assets",\
"target": "assets"\
},\
{\
"source": "static",\
"target": "assets"\
}\
]
}
}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/shortcodes/figure.md)
---
# Deploy with hugo
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Deploy your site with the hugo CLI.
Use the `hugo deploy` command to deploy your site Amazon S3, Azure Blob Storage, or Google Cloud Storage.
This feature requires the Hugo extended/deploy edition. See the [installation](https://gohugo.io/installation/)
section for details.
Assumptions
-----------
1. You have completed the [Quick Start](https://gohugo.io/getting-started/quick-start/)
or have a Hugo website you are ready to deploy and share with the world.
2. You have an account with the service provider ([AWS](https://aws.amazon.com/)
, [Azure](https://azure.microsoft.com/)
, or [Google Cloud](https://cloud.google.com/)
) that you want to deploy to.
3. You have authenticated.
* AWS: [Install the CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html)
and run [`aws configure`](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)
.
* Azure: [Install the CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
and run [`az login`](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli)
.
* Google Cloud: [Install the CLI](https://cloud.google.com/sdk)
and run [`gcloud auth login`](https://cloud.google.com/sdk/gcloud/reference/auth/login)
.
Each service supports various authentication methods, including environment variables. See [details](https://gocloud.dev/howto/blob/#services)
.
4. You have created a bucket to deploy to. If you want your site to be public, be sure to configure the bucket to be publicly readable as a static website.
* AWS: [create a bucket](https://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html)
and [host a static website](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html)
* Azure: [create a storage container](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-portal)
and [host a static website](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website)
* Google Cloud: [create a bucket](https://cloud.google.com/storage/docs/creating-buckets)
and [host a static website](https://cloud.google.com/storage/docs/hosting-static-website)
Configuration
-------------
Create a deployment target in your [project configuration](https://gohugo.io/configuration/deployment/)
. The only required parameters are [`name`](https://gohugo.io/configuration/deployment/#name)
and [`url`](https://gohugo.io/configuration/deployment/#url)
:
deployment:
targets:
- name: production
url: s3://my_bucket?region=us-west-1
[deployment]
[[deployment.targets]]
name = 'production'
url = 's3://my_bucket?region=us-west-1'
{
"deployment": {
"targets": [\
{\
"name": "production",\
"url": "s3://my_bucket?region=us-west-1"\
}\
]
}
}
Deploy
------
To deploy to a target:
hugo deploy [--target=]
This command syncs the contents of your local `public` directory (the default publish directory) with the destination bucket. If no target is specified, Hugo deploys to the first configured target.
For more command-line options, see `hugo help deploy` or the [CLI documentation](https://gohugo.io/commands/hugo_deploy/)
.
### File list creation
`hugo deploy` creates local and remote file lists by traversing the local publish directory and the remote bucket. Inclusion and exclusion are determined by the deployment target’s [configuration](https://gohugo.io/configuration/deployment/#targets-1)
:
* `include`: All files are skipped by default except those that match the pattern.
* `exclude`: Files matching the pattern are skipped.
During local file list creation, Hugo skips `.DS_Store` files and hidden directories (those starting with a period, like `.git`), except for the [`.well-known`](https://en.wikipedia.org/wiki/Well-known_URI)
directory, which is traversed if present.
### File list comparison
Hugo compares the local and remote file lists to identify necessary changes. It first compares file names. If both exist, it compares sizes and MD5 checksums. Any difference triggers a re-upload, and remote files not present locally are deleted.
Excluded remote files (due to `include`/`exclude` configuration) won’t be deleted.
The `--force` flag forces all files to be re-uploaded, even if Hugo detects no local/remote differences.
The `--confirm` or `--dryRun` flags cause Hugo to display the detected differences and then pause or stop.
### Synchronization
Hugo applies the changes to the remote bucket: uploading missing or changed files and deleting remote files not present locally. Uploaded file headers are configured remotely based on the matchers configuration.
To prevent accidental data loss, Hugo will not delete more than 256 remote files by default. Use the `--maxDeletes` flag to override this limit.
Advanced configuration
----------------------
See [configure deployment](https://gohugo.io/configuration/deployment/)
.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/host-and-deploy/deploy-with-hugo-deploy.md)
---
# Content formats
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Create your content using Markdown, HTML, Emacs Org Mode, AsciiDoc, Pandoc, or reStructuredText.
Introduction
------------
You may mix content formats throughout your site. For example:
content/
└── posts/
├── post-1.md
├── post-2.adoc
├── post-3.org
├── post-4.pandoc
├── post-5.rst
└── post-6.html
Regardless of content format, all content must have [front matter](https://gohugo.io/content-management/front-matter/)
, preferably including both `title` and `date`.
Hugo selects the content renderer based on the `markup` identifier in front matter, falling back to the file extension. See the [classification](https://gohugo.io/content-management/formats/#classification)
table below for a list of markup identifiers and recognized file extensions.
Formats
-------
### Markdown
Create your content in [Markdown](https://daringfireball.net/projects/markdown/)
preceded by front matter.
Markdown is Hugo’s default content format. Hugo natively renders Markdown to HTML using [Goldmark](https://github.com/yuin/goldmark)
. Goldmark is fast and conforms to the [CommonMark](https://spec.commonmark.org/current/)
and [GitHub Flavored Markdown](https://github.github.com/gfm/)
specifications. You can configure Goldmark in your [project configuration](https://gohugo.io/configuration/markup/#goldmark)
.
Hugo provides custom Markdown features including:
[Attributes](https://gohugo.io/content-management/markdown-attributes/)
Apply HTML attributes such as `class` and `id` to Markdown images and block elements including blockquotes, fenced code blocks, headings, horizontal rules, lists, paragraphs, and tables.
[Extensions](https://gohugo.io/configuration/markup/#extensions)
Leverage the embedded Markdown extensions to create tables, definition lists, footnotes, task lists, inserted text, mark text, subscripts, superscripts, and more.
[Mathematics](https://gohugo.io/content-management/mathematics/)
Include mathematical equations and expressions in Markdown using LaTeX markup.
[Render hooks](https://gohugo.io/render-hooks/introduction/)
Override the conversion of Markdown to HTML when rendering fenced code blocks, headings, images, and links. For example, render every standalone image as an HTML `figure` element.
### HTML
Create your content in [HTML](https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started/Your_first_website/Creating_the_content)
preceded by front matter. The content is typically what you would place within an HTML document’s `body` or `main` element.
### Emacs Org Mode
Create your content in the [Emacs Org Mode](https://orgmode.org/)
format preceded by front matter. You can use Org Mode keywords for front matter. See [details](https://gohugo.io/content-management/front-matter/#emacs-org-mode)
.
### AsciiDoc
Create your content in the [AsciiDoc](https://asciidoc.org/)
format preceded by front matter. Hugo renders AsciiDoc content to HTML using the Asciidoctor executable. You must install Asciidoctor and its dependencies (Ruby) to render the AsciiDoc content format.
You can configure the AsciiDoc renderer in your [project configuration](https://gohugo.io/configuration/markup/#asciidoc)
.
In its default configuration, Hugo passes these CLI flags when calling the Asciidoctor executable:
--no-header-footer
The CLI flags passed to the Asciidoctor executable depend on configuration. You may inspect the flags when building your project:
hugo build --logLevel info
### Pandoc
Create your content in the [Pandoc](https://pandoc.org/MANUAL.html#pandocs-markdown)
format[1](https://gohugo.io/content-management/formats/#fn:1)
preceded by front matter. Hugo renders Pandoc content to HTML using the Pandoc executable. You must install Pandoc to render the Pandoc content format.
Hugo passes these CLI flags when calling the Pandoc executable:
--mathjax
### reStructuredText
Create your content in the [reStructuredText](https://docutils.sourceforge.io/rst.html)
format preceded by front matter. Hugo renders reStructuredText content to HTML using [Docutils](https://docutils.sourceforge.io/)
, specifically rst2html. You must install Docutils and its dependencies (Python) to render the reStructuredText content format.
Hugo passes these CLI flags when calling the rst2html executable:
--leave-comments --initial-header-level=2
Classification
--------------
| Content format | Media type | Identifier | File extensions |
| --- | --- | --- | --- |
| Markdown | `text/markdown` | `markdown` | `markdown`,`md`, `mdown` |
| HTML | `text/html` | `html` | `htm`, `html` |
| Emacs Org Mode | `text/org` | `org` | `org` |
| AsciiDoc | `text/asciidoc` | `asciidoc` | `ad`, `adoc`, `asciidoc` |
| Pandoc | `text/pandoc` | `pandoc` | `pandoc`, `pdc` |
| reStructuredText | `text/rst` | `rst` | `rst` |
When converting content to HTML, Hugo uses:
* Native renderers for Markdown, HTML, and Emacs Org mode
* External renderers for AsciiDoc, Pandoc, and reStructuredText
Native renderers are faster than external renderers.
* * *
1. This is a derivation of the Markdown format as described by the CommonMark specification. [↩︎](https://gohugo.io/content-management/formats/#fnref:1)
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/content-management/formats.md)
---
# define
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Defines a template.
Syntax
define NAME
Use with the [`block`](https://gohugo.io/functions/go-template/block/)
statement:
{{ block "main" . }}
{{ print "default value if 'main' template is empty" }}
{{ end }}
{{ define "main" }}
{{ .Title }}
{{ .Content }}
{{ end }}
Use with the [`partial`](https://gohugo.io/functions/partials/include/)
function:
{{ partial "inline/foo.html" (dict "answer" 42) }}
{{ define "_partials/inline/foo.html" }}
{{ printf "The answer is %v." .answer }}
{{ end }}
Use with the [`template`](https://gohugo.io/functions/go-template/block/)
function:
{{ template "foo" (dict "answer" 42) }}
{{ define "foo" }}
{{ printf "The answer is %v." .answer }}
{{ end }}
See Go’s [`text/template`](https://pkg.go.dev/text/template)
documentation for more information.
* * *
Last updated: August 23, 2025 : [Merge commit 'bfa74537929f409fca841540b971125b7678963a' (6c911d1e5)](https://github.com/gohugoio/hugoDocs/commit/6c911d1e52fb9c8065c079820327f4b0e37529d4)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/go-template/define.md)
---
# Get
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice of weighted pages to which the given term has been assigned.
Syntax
TAXONOMY.Get TERM
Returns
page.WeightedPages
The `Get` method on a `Taxonomy` object returns a slice of [weighted pages](https://gohugo.io/quick-reference/glossary/#weighted-page)
to which the given [term](https://gohugo.io/quick-reference/glossary/#term)
has been assigned.
Before we can use a `Taxonomy` method, we need to capture a `Taxonomy` object.
Capture a Taxonomy object
-------------------------
Consider this project configuration:
taxonomies:
author: authors
genre: genres
[taxonomies]
author = 'authors'
genre = 'genres'
{
"taxonomies": {
"author": "authors",
"genre": "genres"
}
}
And this content structure:
content/
├── books/
│ ├── and-then-there-were-none.md --> genres: suspense
│ ├── death-on-the-nile.md --> genres: suspense
│ └── jamaica-inn.md --> genres: suspense, romance
│ └── pride-and-prejudice.md --> genres: romance
└── _index.md
To capture the “genres” `Taxonomy` object from within any template, use the [`Taxonomies`](https://gohugo.io/methods/site/taxonomies/)
method on a `Site` object.
{{ $taxonomyObject := .Site.Taxonomies.genres }}
To capture the “genres” `Taxonomy` object when rendering its page with a _taxonomy_ template, use the [`Terms`](https://gohugo.io/methods/page/data/#in-a-taxonomy-template)
method on the page’s [`Data`](https://gohugo.io/methods/page/data/)
object:
layouts/taxonomy.html
{{ $taxonomyObject := .Data.Terms }}
To inspect the data structure:
{{ debug.Dump $taxonomyObject }}
Although the [`Alphabetical`](https://gohugo.io/methods/taxonomy/alphabetical/)
and [`ByCount`](https://gohugo.io/methods/taxonomy/bycount/)
methods provide a better data structure for ranging through the taxonomy, you can render the weighted pages by term directly from the `Taxonomy` object:
{{ range $term, $weightedPages := $taxonomyObject }}
{{ end }}
In the example above, the first anchor element is a link to the term page.
Get the weighted pages
----------------------
Now that we have captured the “genres” `Taxonomy` object, let’s get the weighted pages to which the “suspense” term has been assigned:
{{ $weightedPages := $taxonomyObject.Get "suspense" }}
The above is equivalent to:
{{ $weightedPages := $taxonomyObject.suspense }}
But, if the term is not a valid [identifier](https://gohugo.io/quick-reference/glossary/#identifier)
, you cannot use the [chaining](https://gohugo.io/quick-reference/glossary/#chain)
syntax. For example, this will throw an error because the identifier contains a hyphen:
{{ $weightedPages := $taxonomyObject.my-genre }}
You could also use the [`index`](https://gohugo.io/functions/collections/indexfunction/)
function, but the syntax is more verbose:
{{ $weightedPages := index $taxonomyObject "my-genre" }}
To inspect the data structure:
{{ debug.Dump $weightedPages }}
Example
-------
With this template:
{{ $weightedPages := $taxonomyObject.Get "suspense" }}
{{ range $weightedPages }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/taxonomy/Get.md)
---
# collections.Sort
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a sorted map or slice by reordering the given collection by a key and order.
Syntax
collections.Sort MAP|SLICE \[KEY\] \[ORDER\]
Returns
any
Alias
sort
The `KEY` is optional when sorting slices in ascending order, otherwise it is required. When sorting slices, use the literal `value` in place of the `KEY`. See examples below.
The `ORDER` may be either `asc` (ascending) or `desc` (descending). The default sort order is ascending.
Sort a slice
------------
The examples below assume this project configuration:
params:
grades:
- b
- a
- c
[params]
grades = ['b', 'a', 'c']
{
"params": {
"grades": [\
"b",\
"a",\
"c"\
]
}
}
### Ascending order
Sort slice elements in ascending order using either of these constructs:
{{ sort site.Params.grades }} → [a b c]
{{ sort site.Params.grades "value" "asc" }} → [a b c]
In the examples above, `value` is the `KEY` representing the value of the slice element.
### Descending order
Sort slice elements in descending order:
{{ sort site.Params.grades "value" "desc" }} → [c b a]
In the example above, `value` is the `KEY` representing the value of the slice element.
Sort a map
----------
The examples below assume this project configuration:
params:
authors:
a:
firstName: Marius
lastName: Pontmercy
b:
firstName: Victor
lastName: Hugo
c:
firstName: Jean
lastName: Valjean
[params]
[params.authors]
[params.authors.a]
firstName = 'Marius'
lastName = 'Pontmercy'
[params.authors.b]
firstName = 'Victor'
lastName = 'Hugo'
[params.authors.c]
firstName = 'Jean'
lastName = 'Valjean'
{
"params": {
"authors": {
"a": {
"firstName": "Marius",
"lastName": "Pontmercy"
},
"b": {
"firstName": "Victor",
"lastName": "Hugo"
},
"c": {
"firstName": "Jean",
"lastName": "Valjean"
}
}
}
}
When sorting maps, the `KEY` argument must be lowercase.
### Ascending order
Sort map objects in ascending order using either of these constructs:
{{ range sort site.Params.authors "firstname" }}
{{ .firstName }}
{{ end }}
{{ range sort site.Params.authors "firstname" "asc" }}
{{ .firstName }}
{{ end }}
These produce:
Jean Marius Victor
### Descending order
Sort map objects in descending order:
{{ range sort site.Params.authors "firstname" "desc" }}
{{ .firstName }}
{{ end }}
This produces:
Victor Marius Jean
### First level key removal
Hugo removes the first level keys when sorting a map.
Original map:
{
"felix": {
"breed": "malicious",
"type": "cat"
},
"spot": {
"breed": "boxer",
"type": "dog"
}
}
After sorting:
[\
{\
"breed": "malicious",\
"type": "cat"\
},\
{\
"breed": "boxer",\
"type": "dog"\
}\
]
Sort a page collection
----------------------
Although you can use the `sort` function to sort a page collection, Hugo provides [sorting and grouping methods](https://gohugo.io/methods/pages/)
as well.
In this contrived example, sort the site’s regular pages by `.Type` in descending order:
{{ range sort site.RegularPages "Type" "desc" }}
{{ end }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Sort.md)
---
# Colors
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Applicable to images, returns a slice of the most dominant colors using a simple histogram method.
Syntax
RESOURCE.Colors
Returns
\[\]images.Color
Use this method with [global resources](https://gohugo.io/quick-reference/glossary/#global-resource)
, [page resources](https://gohugo.io/quick-reference/glossary/#page-resource)
, or [remote resources](https://gohugo.io/quick-reference/glossary/#remote-resource)
.
The `Colors` method returns a slice of the most dominant colors in a [processable image](https://gohugo.io/quick-reference/glossary/#processable-image)
, ordered from most dominant to least dominant.
Use the [`reflect.IsImageResourceProcessable`](https://gohugo.io/functions/reflect/isimageresourceprocessable/)
function to verify that an image can be processed.
Usage
-----
This method is fast, but if you downscale your image first, you can further improve performance by extracting colors from the smaller resource.
Methods
-------
Each color in the slice is an object with the following methods:
### ColorHex
(`string`) Returns the [hexadecimal color](https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color)
value, prefixed with a hash sign.
### Luminance
(`float64`) Returns the [relative luminance](https://www.w3.org/TR/WCAG21/#dfn-relative-luminance)
of the color in the sRGB colorspace in the range \[0, 1\]. A value of `0` represents the darkest black, while a value of `1` represents the lightest white.
Image filters such as [`images.Dither`](https://gohugo.io/functions/images/dither/)
, [`images.Padding`](https://gohugo.io/functions/images/padding/)
, and [`images.Text`](https://gohugo.io/functions/images/text/)
accept either hexadecimal color values or `images.Color` objects as arguments. Hugo renders an `images.Color` object as a hexadecimal color value.
Sorting
-------
As a contrived example, create a table of an image’s dominant colors with the most dominant color first, and display the relative luminance of each dominant color:
{{ with resources.Get "images/a.jpg" }}
Color
Relative luminance
{{ range .Colors }}
{{ .ColorHex }}
{{ .Luminance | lang.FormatNumber 4 }}
{{ end }}
{{ end }}
Hugo renders this to:
| ColorHex | Relative luminance |
| --- | --- |
| `#bebebd` | `0.5145` |
| `#514947` | `0.0697` |
| `#768a9a` | `0.2436` |
| `#647789` | `0.1771` |
| `#90725e` | `0.1877` |
| `#a48974` | `0.2704` |
To sort by dominance with the least dominant color first:
{{ range .Colors | collections.Reverse }}
To sort by relative luminance with the darkest color first:
{{ range sort .Colors "Luminance" }}
To sort by relative luminance with the lightest color first, use either of these constructs:
{{ range sort .Colors "Luminance" | collections.Reverse }}
{{ range sort .Colors "Luminance" "desc" }}
Examples
--------
### Image borders
To add a 5 pixel border to an image using the most dominant color:
{{ with resources.Get "images/a.jpg" }}
{{ $mostDominant := index .Colors 0 }}
{{ $filter := images.Padding 5 $mostDominant }}
{{ with .Filter $filter }}
{{ end }}
{{ end }}
To add a 5 pixel border to an image using the darkest dominant color:
{{ with resources.Get "images/a.jpg" }}
{{ $darkest := index (sort .Colors "Luminance") 0 }}
{{ $filter := images.Padding 5 $darkest }}
{{ with .Filter $filter }}
{{ end }}
{{ end }}
### Light text on dark background
To create a text box where the foreground and background colors are derived from an image’s lightest and darkest dominant colors:
{{ with resources.Get "images/a.jpg" }}
{{ $darkest := index (sort .Colors "Luminance") 0 }}
{{ $lightest := index (sort .Colors "Luminance" "desc") 0 }}
{{ end }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pager/First.md)
---
# Config
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a subset of your project configuration.
Syntax
SITE.Config
Returns
page.SiteConfig
The `Config` method on a `Site` object provides access to a subset of your project configuration, specifically the `services` and `privacy` keys.
Services
--------
See [configure services](https://gohugo.io/configuration/services/)
.
For example, to use Hugo’s built-in Google Analytics template you must add a [Google tag ID](https://support.google.com/tagmanager/answer/12326985?hl=en)
:
services:
googleAnalytics:
id: G-XXXXXXXXX
[services]
[services.googleAnalytics]
id = 'G-XXXXXXXXX'
{
"services": {
"googleAnalytics": {
"id": "G-XXXXXXXXX"
}
}
}
To access this value from a template:
{{ .Site.Config.Services.GoogleAnalytics.ID }} → G-XXXXXXXXX
You must capitalize each identifier as shown above.
Privacy
-------
See [configure privacy](https://gohugo.io/configuration/privacy/)
.
For example, to disable usage of the built-in YouTube shortcode:
privacy:
youtube:
disable: true
[privacy]
[privacy.youtube]
disable = true
{
"privacy": {
"youtube": {
"disable": true
}
}
}
To access this value from a template:
{{ .Site.Config.Privacy.YouTube.Disable }} → true
You must capitalize each identifier as shown above.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/site/Config.md)
---
# Data sources
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Use local and remote data sources to augment or create content.
Hugo can access and [unmarshal](https://gohugo.io/quick-reference/glossary/#unmarshal)
local and remote data sources including CSV, JSON, TOML, YAML, and XML. Use this data to augment existing content or to create new content.
A data source might be a file in the `data` directory, a [global resource](https://gohugo.io/quick-reference/glossary/#global-resource)
, a [page resource](https://gohugo.io/quick-reference/glossary/#page-resource)
, or a [remote resource](https://gohugo.io/quick-reference/glossary/#remote-resource)
.
Data directory
--------------
The `data` directory in the root of your project may contain one or more data files, in either a flat or nested tree. Hugo merges the data files to create a single data structure, accessible with the `Data` method on a `Site` object.
Hugo also merges data directories from themes and modules into this single data structure, where the `data` directory in the root of your project takes precedence.
Hugo reads the combined data structure into memory and keeps it there for the entire build. For data that is infrequently accessed, use global or page resources instead.
Theme and module authors may wish to namespace their data files to prevent collisions. For example:
project/
└── data/
└── mytheme/
└── foo.json
Do not place CSV files in the `data` directory. Access CSV files as page, global, or remote resources.
See the documentation for the [`Data`](https://gohugo.io/methods/site/data/)
method on a `Site` object for details and examples.
Global resources
----------------
Use the `resources.Get` and `transform.Unmarshal` functions to access data files that exist as global resources.
See the [`transform.Unmarshal`](https://gohugo.io/functions/transform/unmarshal/#global-resource)
documentation for details and examples.
Page resources
--------------
Use the `Resources.Get` method on a `Page` object combined with the `transform.Unmarshal` function to access data files that exist as page resources.
See the [`transform.Unmarshal`](https://gohugo.io/functions/transform/unmarshal/#page-resource)
documentation for details and examples.
Remote resources
----------------
Use the `resources.GetRemote` and `transform.Unmarshal` functions to access remote data.
See the [`transform.Unmarshal`](https://gohugo.io/functions/transform/unmarshal/#remote-resource)
documentation for details and examples.
Augment existing content
------------------------
Use data sources to augment existing content. For example, create a shortcode to render an HTML table from a global CSV resource.
assets/pets.csv
"name","type","breed","age"
"Spot","dog","Collie","3"
"Felix","cat","Malicious","7"
content/example.md
{{< csv-to-table "pets.csv" >}}
layouts/\_shortcodes/csv-to-table.html
{{ with $file := .Get 0 }}
{{ with resources.Get $file }}
{{ with . | transform.Unmarshal }}
{{ range index . 0 }}
{{ . }}
{{ end }}
{{ range after 1 . }}
{{ range . }}
{{ . }}
{{ end }}
{{ end }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode was unable to find %s. See %s" $.Name $file $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires one positional argument, the path to the CSV file relative to the assets directory. See %s" .Name .Position }}
{{ end }}
Hugo renders this to:
| name | type | breed | age |
| --- | --- | --- | --- |
| Spot | dog | Collie | 3 |
| Felix | cat | Malicious | 7 |
Create new content
------------------
Use [content adapters](https://gohugo.io/content-management/content-adapters/)
to create new content.
* * *
Last updated: July 7, 2025 : [Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45' (079671b41)](https://github.com/gohugoio/hugoDocs/commit/079671b41b9395f2c2b48879f14d3f09d69a63dc)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/content-management/data-sources.md)
---
# Day
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the day of the month of the given time.Time value.
Syntax
TIME.Day
Returns
int
{{ $t := time.AsTime "2023-01-27T23:44:58-08:00" }}
{{ $t.Day }} → 27
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/time/Day.md)
---
# Get
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the value of the given argument.
Syntax
SHORTCODE.Get ARG
Returns
any
Specify the argument by position or by name. When calling a shortcode within Markdown, use either positional or named argument, but not both.
Some shortcodes support positional arguments, some support named arguments, and others support both. Refer to the shortcode’s documentation for usage details.
Positional arguments
--------------------
This shortcode call uses positional arguments:
content/about.md
{{< myshortcode "Hello" "world" >}}
To retrieve arguments by position:
layouts/\_shortcodes/myshortcode.html
{{ printf "%s %s." (.Get 0) (.Get 1) }} → Hello world.
Named arguments
---------------
This shortcode call uses named arguments:
content/about.md
{{< myshortcode greeting="Hello" firstName="world" >}}
To retrieve arguments by name:
layouts/\_shortcodes/myshortcode.html
{{ printf "%s %s." (.Get "greeting") (.Get "firstName") }} → Hello world.
Argument names are case-sensitive.
* * *
Last updated: July 7, 2025 : [Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45' (079671b41)](https://github.com/gohugoio/hugoDocs/commit/079671b41b9395f2c2b48879f14d3f09d69a63dc)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/shortcode/Get.md)
---
# Content adapters
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Create content adapters to dynamically add content when building your project.
Overview
--------
A content adapter is a template that dynamically creates pages when building a site. For example, use a content adapter to create pages from a remote data source such as JSON, TOML, YAML, or XML.
Unlike templates that reside in the `layouts` directory, content adapters reside in the `content` directory, no more than one per directory per language. When a content adapter creates a page, the page’s [logical path](https://gohugo.io/quick-reference/glossary/#logical-path)
will be relative to the content adapter.
content/
├── articles/
│ ├── _index.md
│ ├── article-1.md
│ └── article-2.md
├── books/
│ ├── _content.gotmpl <-- content adapter
│ └── _index.md
└── films/
├── _content.gotmpl <-- content adapter
└── _index.md
Each content adapter is named `_content.gotmpl` and uses the same [syntax](https://gohugo.io/templates/introduction/)
as templates in the `layouts` directory. You can use any of the [template functions](https://gohugo.io/functions/)
within a content adapter, as well as the methods described below.
Methods
-------
Use these methods within a content adapter.
### AddPage
Adds a page to the site.
content/books/\_content.gotmpl
{{ $content := dict
"mediaType" "text/markdown"
"value" "The _Hunchback of Notre Dame_ was written by Victor Hugo."
}}
{{ $page := dict
"content" $content
"kind" "page"
"path" "the-hunchback-of-notre-dame"
"title" "The Hunchback of Notre Dame"
}}
{{ .AddPage $page }}
### AddResource
Adds a page resource to the site.
content/books/\_content.gotmpl
{{ with resources.Get "images/a.jpg" }}
{{ $content := dict
"mediaType" .MediaType.Type
"value" .
}}
{{ $resource := dict
"content" $content
"path" "the-hunchback-of-notre-dame/cover.jpg"
}}
{{ $.AddResource $resource }}
{{ end }}
Then retrieve the new page resource with something like:
layouts/page.html
{{ with .Resources.Get "cover.jpg" }}
{{ end }}
### Site
Returns the `Site` to which the pages will be added.
content/books/\_content.gotmpl
{{ .Site.Title }}
Note that the `Site` returned isn’t fully built when invoked from the content adapters; if you try to call methods that depends on pages, e.g. `.Site.Pages`, you will get an error saying “this method cannot be called before the site is fully initialized”.
### Store
Returns a persistent “scratch pad” to store and manipulate data. The main use case for this is to transfer values between executions when [EnableAllLanguages](https://gohugo.io/content-management/content-adapters/#enablealllanguages)
is set. See [examples](https://gohugo.io/methods/page/store/)
.
content/books/\_content.gotmpl
{{ .Store.Set "key" "value" }}
{{ .Store.Get "key" }}
### EnableAllLanguages
By default, Hugo executes the content adapter only once for the first matching site in the [sites matrix](https://gohugo.io/quick-reference/glossary/#sites-matrix)
. Use this method to expand execution to all languages while maintaining the current role and version.
For more fine-grained control, define a `sites.matrix` in front matter or in a content mount.
content/books/\_content.gotmpl
{{ .EnableAllLanguages }}
{{ $content := dict
"mediaType" "text/markdown"
"value" "The _Hunchback of Notre Dame_ was written by Victor Hugo."
}}
{{ $page := dict
"content" $content
"kind" "page"
"path" "the-hunchback-of-notre-dame"
"title" "The Hunchback of Notre Dame"
}}
{{ .AddPage $page }}
### EnableAllDimensions
By default, Hugo executes the content adapter only once for the first matching site in the [sites matrix](https://gohugo.io/quick-reference/glossary/#sites-matrix)
. Use this method to expand execution to every possible combination of language, version, and role.
For more fine-grained control, define a `sites.matrix` in front matter or in a content mount.
[New in v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
Page map
--------
Set any [front matter field](https://gohugo.io/content-management/front-matter/#fields)
in the map passed to the [`AddPage`](https://gohugo.io/content-management/content-adapters/#addpage)
method, excluding `markup`. Instead of setting the `markup` field, specify the `content.mediaType` as described below.
This table describes the fields most commonly passed to the `AddPage` method.
| Key | Description | Required |
| --- | --- | --- |
| `content.mediaType` | The content [media type](https://en.wikipedia.org/wiki/Media_type) . Default is `text/markdown`. See [content formats](https://gohugo.io/content-management/formats/#classification) for examples. | |
| `content.value` | The content value as a string. | |
| `dates.date` | The page creation date as a `time.Time` value. | |
| `dates.expiryDate` | The page expiry date as a `time.Time` value. | |
| `dates.lastmod` | The page last modification date as a `time.Time` value. | |
| `dates.publishDate` | The page publication date as a `time.Time` value. | |
| `params` | A map of page parameters. | |
| `path` | The page’s [logical path](https://gohugo.io/quick-reference/glossary/#logical-path) relative to the content adapter. Do not include a leading slash or file extension. | ✔️ |
| `title` | The page title. | |
While `path` is the only required field, we recommend setting `title` as well.
When setting the `path`, Hugo transforms the given string to a logical path. For example, setting `path` to `A B C` produces a logical path of `/section/a-b-c`.
Resource map
------------
Construct the map passed to the [`AddResource`](https://gohugo.io/content-management/content-adapters/#addresource)
method using the fields below.
| Key | Description | Required |
| --- | --- | --- |
| `content.mediaType` | The content [media type](https://en.wikipedia.org/wiki/Media_type) . | ✔️ |
| `content.value` | The content value as a string or resource. | ✔️ |
| `name` | The resource name. | |
| `params` | A map of resource parameters. | |
| `path` | The resources’s [logical path](https://gohugo.io/quick-reference/glossary/#logical-path) relative to the content adapter. Do not include a leading slash. | ✔️ |
| `title` | The resource title. | |
When `content.value` is a string, Hugo generates a new resource with a publication path relative to the page. However, if `content.value` is already a resource, Hugo directly uses its value and publishes it relative to the site root. This latter method is more efficient.
When setting the `path`, Hugo transforms the given string to a logical path. For example, setting `path` to `A B C/cover.jpg` produces a logical path of `/section/a-b-c/cover.jpg`.
Example
-------
Create pages from remote data, where each page represents a book review.
Step 1
Create the content structure.
content/
└── books/
├── _content.gotmpl <-- content adapter
└── _index.md
Step 2
Inspect the remote data to determine how to map key-value pairs to front matter fields.
[https://gohugo.io/shared/examples/data/books.json](https://gohugo.io/shared/examples/data/books.json)
Step 3
Create the content adapter.
content/books/\_content.gotmpl
{{/* Get remote data. */}}
{{ $data := dict }}
{{ $url := "https://gohugo.io/shared/examples/data/books.json" }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "Unable to get remote resource %s: %s" $url . }}
{{ else with .Value }}
{{ $data = . | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %s" $url }}
{{ end }}
{{ end }}
{{/* Add pages and page resources. */}}
{{ range $data }}
{{/* Add page. */}}
{{ $content := dict "mediaType" "text/markdown" "value" .summary }}
{{ $dates := dict "date" (time.AsTime .date) }}
{{ $params := dict "author" .author "isbn" .isbn "rating" .rating "tags" .tags }}
{{ $page := dict
"content" $content
"dates" $dates
"kind" "page"
"params" $params
"path" .title
"title" .title
}}
{{ $.AddPage $page }}
{{/* Add page resource. */}}
{{ $item := . }}
{{ with $url := $item.cover }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "Unable to get remote resource %s: %s" $url . }}
{{ else with .Value }}
{{ $content := dict "mediaType" .MediaType.Type "value" .Content }}
{{ $params := dict "alt" $item.title }}
{{ $resource := dict
"content" $content
"params" $params
"path" (printf "%s/cover.%s" $item.title .MediaType.SubType)
}}
{{ $.AddResource $resource }}
{{ else }}
{{ errorf "Unable to get remote resource %s" $url }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
Step 4
Create a _page_ template to render each book review.
layouts/books/page.html
{{ define "main" }}
{{ .Title }}
{{ with .Resources.GetMatch "cover.*" }}
{{ end }}
{{ end }}
{{ .Content }}
{{ end }}
Multilingual projects
---------------------
With multilingual projects you can:
1. Create one content adapter for all languages using the [`EnableAllLanguages`](https://gohugo.io/content-management/content-adapters/#enablealllanguages)
method as described above.
2. Create content adapters unique to each language. See the examples below.
### Translations by file name
With this project configuration:
languages:
de:
weight: 2
en:
weight: 1
[languages]
[languages.de]
weight = 2
[languages.en]
weight = 1
{
"languages": {
"de": {
"weight": 2
},
"en": {
"weight": 1
}
}
}
Include a language designator in the content adapter’s file name.
content/
└── books/
├── _content.de.gotmpl
├── _content.en.gotmpl
├── _index.de.md
└── _index.en.md
### Translations by content directory
With this project configuration:
languages:
de:
contentDir: content/de
weight: 2
en:
contentDir: content/en
weight: 1
[languages]
[languages.de]
contentDir = 'content/de'
weight = 2
[languages.en]
contentDir = 'content/en'
weight = 1
{
"languages": {
"de": {
"contentDir": "content/de",
"weight": 2
},
"en": {
"contentDir": "content/en",
"weight": 1
}
}
}
Create a single content adapter in each directory:
content/
├── de/
│ └── books/
│ ├── _content.gotmpl
│ └── _index.md
└── en/
└── books/
├── _content.gotmpl
└── _index.md
Page collisions
---------------
Two or more pages collide when they have the same publication path. Due to concurrency, the content of the published page is indeterminate. Consider this example:
content/
└── books/
├── _content.gotmpl <-- content adapter
├── _index.md
└── the-hunchback-of-notre-dame.md
If the content adapter also creates `books/the-hunchback-of-notre-dame`, the content of the published page is indeterminate. You can not define the processing order.
To detect page collisions, use the `--printPathWarnings` flag when building your project.
* * *
Last updated: February 26, 2026 : [content: More site-to-project changes (05b69f84e)](https://github.com/gohugoio/hugoDocs/commit/05b69f84e25e9cdd10ed1ac7ce5d37d4ac0b3725)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/content-management/content-adapters.md)
---
# collections.Where
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice by filtering the given slice based on a key, operator, and value.
Syntax
collections.Where SLICE KEY \[OPERATOR\] VALUE
Returns
\[\]any
Alias
where
The `where` function returns the given slice, removing elements that do not satisfy the comparison condition. The comparison condition is composed of the `KEY`, `OPERATOR`, and `VALUE` arguments:
collections.Where SLICE KEY [OPERATOR] VALUE
--------------------
comparison condition
Hugo will test for equality if you do not provide an `OPERATOR` argument. For example:
{{ $pages := where .Site.RegularPages "Section" "books" }}
{{ $books := where hugo.Data.books "genres" "suspense" }}
Arguments
---------
The where function takes three or four arguments. The `OPERATOR` argument is optional.
SLICE
(`[]any`) A [page collection](https://gohugo.io/quick-reference/glossary/#page-collection)
or a [slice](https://gohugo.io/quick-reference/glossary/#slice)
of [maps](https://gohugo.io/quick-reference/glossary/#map)
.
KEY
(`string`) The key of the page or map value to compare with `VALUE`. With page collections, commonly used comparison keys are `Section`, `Type`, and `Params`. To compare with a member of the page `Params` map, [chain](https://gohugo.io/quick-reference/glossary/#chain)
the subkey as shown below:
{{ $result := where .Site.RegularPages "Params.foo" "bar" }}
OPERATOR
(`string`) The logical comparison [operator](https://gohugo.io/functions/collections/where/#operators)
.
VALUE
(`any`) The value with which to compare. The values to compare must have comparable data types. For example:
| Comparison | Result |
| --- | --- |
| `"123" "eq" "123"` | `true` |
| `"123" "eq" 123` | `false` |
| `false "eq" "false"` | `false` |
| `false "eq" false` | `true` |
When one or both of the values to compare is a slice, use the `in`, `not in`, or `intersect` operators as described below.
Operators
---------
Use any of the following logical operators:
`=`, `==`, `eq`
(`bool`) Reports whether the given field value is equal to `VALUE`.
`!=`, `<>`, `ne`
(`bool`) Reports whether the given field value is not equal to `VALUE`.
`>=`, `ge`
(`bool`) Reports whether the given field value is greater than or equal to `VALUE`.
`>`, `gt`
`true` Reports whether the given field value is greater than `VALUE`.
`<=`, `le`
(`bool`) Reports whether the given field value is less than or equal to `VALUE`.
`<`, `lt`
(`bool`) Reports whether the given field value is less than `VALUE`.
`in`
(`bool`) Reports whether the given field value is a member of `VALUE`. Compare string to slice, or string to string. See [details](https://gohugo.io/functions/collections/in/)
.
`not in`
(`bool`) Reports whether the given field value is not a member of `VALUE`. Compare string to slice, or string to string. See [details](https://gohugo.io/functions/collections/in/)
.
`intersect`
(`bool`) Reports whether the given field value (a slice) contains one or more elements in common with `VALUE`. See [details](https://gohugo.io/functions/collections/intersect/)
.
`like`
(`bool`) Reports whether the given field value matches the [regular expression](https://gohugo.io/quick-reference/glossary/#regular-expression)
specified in `VALUE`. Use the `like` operator to compare `string` values. The `like` operator returns `false` when comparing other data types to the regular expression.
The examples below perform comparisons within a page collection, but the same comparisons are applicable to a slice of maps.
String comparison
-----------------
Compare the value of the given field to a [`string`](https://gohugo.io/quick-reference/glossary/#string)
:
{{ $pages := where .Site.RegularPages "Section" "eq" "books" }}
{{ $pages := where .Site.RegularPages "Section" "ne" "books" }}
Numeric comparison
------------------
Compare the value of the given field to an [`int`](https://gohugo.io/quick-reference/glossary/#int)
or [`float`](https://gohugo.io/quick-reference/glossary/#float)
:
{{ $books := where site.RegularPages "Section" "eq" "books" }}
{{ $pages := where $books "Params.price" "eq" 42 }}
{{ $pages := where $books "Params.price" "ne" 42.67 }}
{{ $pages := where $books "Params.price" "ge" 42 }}
{{ $pages := where $books "Params.price" "gt" 42.67 }}
{{ $pages := where $books "Params.price" "le" 42 }}
{{ $pages := where $books "Params.price" "lt" 42.67 }}
Boolean comparison
------------------
Compare the value of the given field to a [`bool`](https://gohugo.io/quick-reference/glossary/#bool)
:
{{ $books := where site.RegularPages "Section" "eq" "books" }}
{{ $pages := where $books "Params.fiction" "eq" true }}
{{ $pages := where $books "Params.fiction" "eq" false }}
{{ $pages := where $books "Params.fiction" "ne" true }}
{{ $pages := where $books "Params.fiction" "ne" false }}
Member comparison
-----------------
Compare a [`scalar`](https://gohugo.io/quick-reference/glossary/#scalar)
to a [`slice`](https://gohugo.io/quick-reference/glossary/#slice)
.
For example, to return a slice of pages where the `color` page parameter is either “red” or “yellow”:
{{ $fruit := where site.RegularPages "Section" "eq" "fruit" }}
{{ $colors := slice "red" "yellow" }}
{{ $pages := where $fruit "Params.color" "in" $colors }}
To return a slice of pages where the “color” page parameter is neither “red” nor “yellow”:
{{ $fruit := where site.RegularPages "Section" "eq" "fruit" }}
{{ $colors := slice "red" "yellow" }}
{{ $pages := where $fruit "Params.color" "not in" $colors }}
Intersection comparison
-----------------------
Compare a `slice` to a `slice`, returning elements with common values. This is frequently used when comparing taxonomy terms.
For example, to return a slice of pages where any of the terms in the “genres” taxonomy are “suspense” or “romance”:
{{ $books := where site.RegularPages "Section" "eq" "books" }}
{{ $genres := slice "suspense" "romance" }}
{{ $pages := where $books "Params.genres" "intersect" $genres }}
Regular expression comparison
-----------------------------
To return a slice of pages where the “author” page parameter begins with either “victor” or “Victor”:
{{ $pages := where .Site.RegularPages "Params.author" "like" `(?i)^victor` }}
When specifying the regular expression, use a raw [string literal](https://go.dev/ref/spec#String_literals)
(backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes.
Go’s regular expression package implements the [RE2 syntax](https://github.com/google/re2/wiki/Syntax/)
. The RE2 syntax is a subset of that accepted by [PCRE](https://www.pcre.org/)
, roughly speaking, and with various [caveats](https://swtch.com/~rsc/regexp/regexp3.html#caveats)
. Note that the RE2 `\C` escape sequence is not supported.
Use the `like` operator to compare string values. Comparing other data types will result in an empty slice.
Date comparison
---------------
### Predefined dates
There are four predefined front matter dates: [`date`](https://gohugo.io/methods/page/date/)
, \[`publishDate`\], [`lastmod`](https://gohugo.io/methods/page/lastmod/)
, and \[`expiryDate`\]. Regardless of the front matter data format (TOML, YAML, or JSON) these are [`time.Time`](https://pkg.go.dev/time#Time)
values, allowing precise comparisons.
For example, to return a slice of pages that were created before the current year:
{{ $startOfYear := time.AsTime (printf "%d-01-01" now.Year) }}
{{ $pages := where .Site.RegularPages "Date" "lt" $startOfYear }}
### Custom dates
With custom front matter dates, the comparison depends on the front matter data format (TOML, YAML, or JSON).
Using TOML for pages with custom front matter dates enables precise date comparisons.
With TOML, date values are first-class citizens. TOML has a date data type while JSON and YAML do not. If you quote a TOML date, it is a string. If you do not quote a TOML date value, it is [`time.Time`](https://pkg.go.dev/time#Time)
value, enabling precise comparisons.
In the TOML example below, note that the event date is not quoted.
content/events/2024-user-conference.md
+++
title = '2024 User Conference"
eventDate = 2024-04-01
+++
To return a slice of future events:
{{ $events := where .Site.RegularPages "Type" "events" }}
{{ $futureEvents := where $events "Params.eventDate" "gt" now }}
When working with YAML or JSON, or quoted TOML values, custom dates are strings; you cannot compare them with `time.Time` values. String comparisons may be possible if the custom date layout is consistent from one page to the next. To be safe, filter the pages by ranging over the slice:
{{ $events := where .Site.RegularPages "Type" "events" }}
{{ $futureEvents := slice }}
{{ range $events }}
{{ if gt (time.AsTime .Params.eventDate) now }}
{{ $futureEvents = $futureEvents | append . }}
{{ end }}
{{ end }}
Nil comparison
--------------
To return a slice of pages where the “color” parameter is present in front matter, compare to `nil`:
{{ $pages := where .Site.RegularPages "Params.color" "ne" nil }}
To return a slice of pages where the “color” parameter is not present in front matter, compare to `nil`:
{{ $pages := where .Site.RegularPages "Params.color" "eq" nil }}
In both examples above, note that `nil` is not quoted.
Nested comparison
-----------------
These are equivalent:
{{ $pages := where .Site.RegularPages "Type" "tutorials" }}
{{ $pages = where $pages "Params.level" "eq" "beginner" }}
{{ $pages := where (where .Site.RegularPages "Type" "tutorials") "Params.level" "eq" "beginner" }}
Portable section comparison
---------------------------
Useful for theme authors, avoid hardcoding section names by using the `where` function with the [`MainSections`](https://gohugo.io/methods/site/mainsections/)
method on a `Site` object.
{{ $pages := where .Site.RegularPages "Section" "in" .Site.MainSections }}
With this construct, a theme author can instruct users to specify their main sections in their project configuration:
mainSections:
- blog
- galleries
mainSections = ['blog', 'galleries']
{
"mainSections": [\
"blog",\
"galleries"\
]
}
If `mainSections` is not defined in your project configuration, the `MainSections` method returns a slice with one element—the top-level section with the most pages.
Boolean/undefined comparison
----------------------------
Consider this project structure:
content/
├── posts/
│ ├── _index.md
│ ├── post-1.md <-- front matter: exclude = false
│ ├── post-2.md <-- front matter: exclude = true
│ └── post-3.md <-- front matter: exclude not defined
└── _index.md
The first two pages have an “exclude” field in front matter, but the last page does not. When testing for _equality_, the third page is _excluded_ from the result. When testing for _inequality_, the third page is _included_ in the result.
### Equality test
This template:
{{ range where .Site.RegularPages "Params.exclude" "eq" false }}
To exclude a page with an undefined field from a boolean _inequality_ test:
1. Create a slice using a boolean comparison
2. Create a slice using a nil comparison
3. Subtract the second slice from the first slice using the [`collections.Complement`](https://gohugo.io/functions/collections/complement/)
function.
This template:
{{ $p1 := where .Site.RegularPages "Params.exclude" "ne" true }}
{{ $p2 := where .Site.RegularPages "Params.exclude" "eq" nil }}
* * *
Last updated: February 26, 2026 : [content: More site-to-project changes (05b69f84e)](https://github.com/gohugoio/hugoDocs/commit/05b69f84e25e9cdd10ed1ac7ce5d37d4ac0b3725)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/functions/collections/Where.md)
---
# Data
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a data structure composed from the files in the data directory.
Syntax
SITE.Data
Returns
map
Deprecated in [v0.156.0](https://github.com/gohugoio/hugo/releases/tag/v0.156.0)
Use [`hugo.Data`](https://gohugo.io/functions/hugo/data/)
instead.
* * *
Last updated: March 2, 2026 : [content: Clean up content for deprecated features (850dc5b2b)](https://github.com/gohugoio/hugoDocs/commit/850dc5b2b26b7136504b24a46d6abede248c0fed)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/site/Data.md)
---
# Exif
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns an object containing Exif metadata for supported image formats.
Syntax
RESOURCE.Exif
Returns
meta.ExifInfo
Deprecated in [v0.155.0](https://github.com/gohugoio/hugo/releases/tag/v0.155.0)
Use [`Meta`](https://gohugo.io/methods/resource/meta/)
instead.
* * *
Last updated: March 2, 2026 : [content: Clean up content for deprecated features (850dc5b2b)](https://github.com/gohugoio/hugoDocs/commit/850dc5b2b26b7136504b24a46d6abede248c0fed)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/resource/Exif.md)
---
# Err
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Applicable to resources returned by the resources.GetRemote function, returns an error message if the HTTP request fails, else nil.
Syntax
RESOURCE.Err
Returns
resource.resourceError
Deprecated in [v0.141.0](https://github.com/gohugoio/hugo/releases/tag/v0.141.0)
Use the `try` statement instead. See [example](https://gohugo.io/functions/go-template/try/#example)
.
* * *
Last updated: March 2, 2026 : [content: Clean up content for deprecated features (850dc5b2b)](https://github.com/gohugoio/hugoDocs/commit/850dc5b2b26b7136504b24a46d6abede248c0fed)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/resource/Err.md)
---
# Go template functions, operators, and statements
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

[### and\
\
and VALUE...\
\
Returns the first falsy argument. If all arguments are truthy, returns the last argument.](https://gohugo.io/functions/go-template/and/)
[### block\
\
block NAME CONTEXT\
\
Defines a template and executes it in place.](https://gohugo.io/functions/go-template/block/)
[### break\
\
break\
\
Used with the range statement, stops the innermost iteration and bypasses all remaining iterations.](https://gohugo.io/functions/go-template/break/)
[### continue\
\
continue\
\
Used with the range statement, stops the innermost iteration and continues to the next iteration.](https://gohugo.io/functions/go-template/continue/)
[### define\
\
define NAME\
\
Defines a template.](https://gohugo.io/functions/go-template/define/)
[### else\
\
else VALUE\
\
Begins an alternate block for if, with, and range statements.](https://gohugo.io/functions/go-template/else/)
[### end\
\
end\
\
Terminates if, with, range, block, and define statements.](https://gohugo.io/functions/go-template/end/)
[### if\
\
if EXPR\
\
Executes the block if the expression is truthy.](https://gohugo.io/functions/go-template/if/)
[### len\
\
len VALUE\
\
Returns the length of a string, slice, map, or collection.](https://gohugo.io/functions/go-template/len/)
[### not\
\
not VALUE\
\
Returns the boolean negation of its single argument.](https://gohugo.io/functions/go-template/not/)
[### or\
\
or VALUE...\
\
Returns the first truthy argument. If all arguments are falsy, returns the last argument.](https://gohugo.io/functions/go-template/or/)
[### range\
\
range COLLECTION\
\
Iterates over a non-empty collection, binds context (the dot) to successive elements, and executes the block.](https://gohugo.io/functions/go-template/range/)
[### return\
\
return \[VALUE\]\
\
Used within partial templates, terminates template execution and returns the given value, if any.](https://gohugo.io/functions/go-template/return/)
[### template\
\
template NAME \[CONTEXT\]\
\
Executes the given template, optionally passing context.](https://gohugo.io/functions/go-template/template/)
[### try\
\
try EXPRESSION\
\
Returns a TryValue object after evaluating the given expression.](https://gohugo.io/functions/go-template/try/)
[### urlquery\
\
urlquery VALUE \[VALUE...\]\
\
Returns the escaped value of the textual representation of its arguments in a form suitable for embedding in a URL query.](https://gohugo.io/functions/go-template/urlquery/)
[### with\
\
with EXPR\
\
Binds context (the dot) to the expression and executes the block if expression is truthy.](https://gohugo.io/functions/go-template/with/)
---
# Configure content types
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Configure content types.
[New in v0.144.0](https://github.com/gohugoio/hugo/releases/tag/v0.144.0)
Hugo supports six [content formats](https://gohugo.io/quick-reference/glossary/#content-format)
:
| Content format | Media type | Identifier | File extensions |
| --- | --- | --- | --- |
| Markdown | `text/markdown` | `markdown` | `markdown`,`md`, `mdown` |
| HTML | `text/html` | `html` | `htm`, `html` |
| Emacs Org Mode | `text/org` | `org` | `org` |
| AsciiDoc | `text/asciidoc` | `asciidoc` | `ad`, `adoc`, `asciidoc` |
| Pandoc | `text/pandoc` | `pandoc` | `pandoc`, `pdc` |
| reStructuredText | `text/rst` | `rst` | `rst` |
These can be used as either page content or [page resources](https://gohugo.io/quick-reference/glossary/#page-resource)
. When used as page resources, their [resource type](https://gohugo.io/quick-reference/glossary/#resource-type)
is `page`.
Consider this example of a [page bundle](https://gohugo.io/quick-reference/glossary/#page-bundle)
:
content/
└── example/
├── index.md <-- content
├── a.adoc <-- resource (resource type: page)
├── b.html <-- resource (resource type: page)
├── c.md <-- resource (resource type: page)
├── d.org <-- resource (resource type: page)
├── e.pdc <-- resource (resource type: page)
├── f.rst <-- resource (resource type: page)
├── g.jpg <-- resource (resource type: image)
└── h.png <-- resource (resource type: image)
The `index.md` file is the page’s content, while the other files are page resources. Files `a` through `f` are of resource type `page`, while `g` and `h` are of resource type `image`.
When you build a site, Hugo does not publish page resources having a resource type of `page`. For example, this is the result of building the site above:
public/
├── example/
│ ├── g.jpg
│ ├── h.png
│ └── index.html
└── index.html
The default behavior is appropriate in most cases. Given that page resources containing markup are typically intended for inclusion in the main content, publishing them independently is generally undesirable.
The default behavior is determined by the `contentTypes` configuration:
contentTypes:
text/asciidoc: {}
text/html: {}
text/markdown: {}
text/org: {}
text/pandoc: {}
text/rst: {}
[contentTypes]
[contentTypes.'text/asciidoc']
[contentTypes.'text/html']
[contentTypes.'text/markdown']
[contentTypes.'text/org']
[contentTypes.'text/pandoc']
[contentTypes.'text/rst']
{
"contentTypes": {
"text/asciidoc": {},
"text/html": {},
"text/markdown": {},
"text/org": {},
"text/pandoc": {},
"text/rst": {}
}
}
In this default configuration, page resources with those media types will have a resource type of `page`, and will not be automatically published. To change the resource type assignment from `page` to `text` for a given media type, remove the corresponding entry from the list.
For example, to set the resource type of `text/html` files to `text`, thereby enabling automatic publication, remove the `text/html` entry:
contentTypes:
text/asciidoc: {}
text/markdown: {}
text/org: {}
text/pandoc: {}
text/rst: {}
[contentTypes]
[contentTypes.'text/asciidoc']
[contentTypes.'text/markdown']
[contentTypes.'text/org']
[contentTypes.'text/pandoc']
[contentTypes.'text/rst']
{
"contentTypes": {
"text/asciidoc": {},
"text/markdown": {},
"text/org": {},
"text/pandoc": {},
"text/rst": {}
}
}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/configuration/content-types.md)
---
# HasChildren
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports whether the given menu entry has child menu entries.
Syntax
MENUENTRY.HasChildren
Returns
bool
Use the `HasChildren` method when rendering a nested menu.
With this project configuration:
menus:
main:
- name: Products
pageRef: /product
weight: 10
- name: Product 1
pageRef: /products/product-1
parent: Products
weight: 1
- name: Product 2
pageRef: /products/product-2
parent: Products
weight: 2
[menus]
[[menus.main]]
name = 'Products'
pageRef = '/product'
weight = 10
[[menus.main]]
name = 'Product 1'
pageRef = '/products/product-1'
parent = 'Products'
weight = 1
[[menus.main]]
name = 'Product 2'
pageRef = '/products/product-2'
parent = 'Products'
weight = 2
{
"menus": {
"main": [\
{\
"name": "Products",\
"pageRef": "/product",\
"weight": 10\
},\
{\
"name": "Product 1",\
"pageRef": "/products/product-1",\
"parent": "Products",\
"weight": 1\
},\
{\
"name": "Product 2",\
"pageRef": "/products/product-2",\
"parent": "Products",\
"weight": 2\
}\
]
}
}
And this template:
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/menu-entry/HasChildren.md)
---
# Dimension
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the dimension object for the given dimension for the given site.
Syntax
SITE.Dimension DIMENSION
Returns
page.SiteDimension
[New in v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
The `Dimension` method on a `Site` object returns the dimension object for the given [dimension](https://gohugo.io/quick-reference/glossary/#dimension)
.
The `DIMENSION` argument must be one of `language`, `version`, or `role`.
| Example | Returns | Equivalent to |
| --- | --- | --- |
| `{{ .Site.Dimension "language" }}` | `langs.Language` | `{{ .Site.Language }}` |
| `{{ .Site.Dimension "version" }}` | `version.Version` | `{{ .Site.Version }}` |
| `{{ .Site.Dimension "role" }}` | `roles.Role` | `{{ .Site.Role }}` |
{{ $languageObject := .Site.Dimension "language" }}
{{ $languageObject.IsDefault }} → true
{{ $languageObject.Name }} → en
{{ $versionObject := .Site.Dimension "version" }}
{{ $versionObject.IsDefault }} → true
{{ $versionObject.Name }} → v1.0.0
{{ $roleObject := .Site.Dimension "role" }}
{{ $roleObject.IsDefault }} → true
{{ $roleObject.Name }} → guest
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/site/Dimension.md)
---
# Equal
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports whether TIME1 is equal to TIME2.
Syntax
TIME1.Equal TIME2
Returns
bool
{{ $t1 := time.AsTime "2023-01-01T17:00:00-08:00" }}
{{ $t2 := time.AsTime "2023-01-01T20:00:00-05:00" }}
{{ $t1.Equal $t2 }} → true
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/time/Equal.md)
---
# Fill
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Applicable to images, returns a new image resource cropped and resized according to the given processing specification.
Syntax
RESOURCE.Fill SPECIFICATION
Returns
images.ImageResource
Use this method with [global resources](https://gohugo.io/quick-reference/glossary/#global-resource)
, [page resources](https://gohugo.io/quick-reference/glossary/#page-resource)
, or [remote resources](https://gohugo.io/quick-reference/glossary/#remote-resource)
.
The `Fill` method returns a new resource from a [processable image](https://gohugo.io/quick-reference/glossary/#processable-image)
according to the given [processing specification](https://gohugo.io/methods/resource/fill/#processing-specification)
.
Use the [`reflect.IsImageResourceProcessable`](https://gohugo.io/functions/reflect/isimageresourceprocessable/)
function to verify that an image can be processed.
Usage
-----
When filling, you must provide both width and height (such as `500x200`) within the specification. `Fill` maintains the original aspect ratio by resizing the image to cover the target area and cropping any overflowing pixels based on the [anchor](https://gohugo.io/methods/resource/fill/#anchor)
provided.
{{ with resources.Get "images/original.jpg" }}
{{ with .Fill "500x200 TopRight" }}
{{ end }}
{{ end }}
In the example above, `"500x200 TopRight"` is the \_processing specification.
Processing specification
------------------------
The processing specification is a space-delimited, case-insensitive list containing one or more of the following options in any sequence:
action
Specify one of `crop`, `fill`, `fit`, or `resize`. This is applicable to the [`Process`](https://gohugo.io/methods/resource/process/)
method and the [`images.Process`](https://gohugo.io/functions/images/process/)
filter. If you specify an action, you must also provide dimensions.
anchor
The focal point used when cropping or filling an image. Valid options include `TopLeft`, `Top`, `TopRight`, `Left`, `Center`, `Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`. The `Smart` option utilizes the [`muesli/smartcrop`](https://github.com/muesli/smartcrop)
package to identify the most interesting area of the image. This defaults to the [`anchor`](https://gohugo.io/configuration/imaging/#anchor)
parameter in your project configuration.
background color
The background color used when converting transparent images to formats that do not support transparency, such as PNG to JPEG. This color also fills the empty space created when rotating an image by a non-orthogonal angle if the space is not transparent and a background color is not specified in the processing specification. The value must be an RGB [hexadecimal color](https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color)
. This defaults to the [`bgColor`](https://gohugo.io/configuration/imaging/#bgcolor)
parameter in your project configuration.
compression
[New in v0.153.5](https://github.com/gohugoio/hugo/releases/tag/v0.153.5)
The encoding strategy used for the image. Options are `lossy` or `lossless`. Note that `lossless` is only supported by the WebP format. This defaults to the [`compression`](https://gohugo.io/configuration/imaging/#compression)
parameter in your project configuration.
dimensions
The dimensions of the resulting image, in pixels. The format is `WIDTHxHEIGHT` where `WIDTH` and `HEIGHT` are whole numbers. When resizing an image, you may specify only the width (such as `600x`) or only the height (such as `x400`) for proportional scaling. Specifying both width and height when resizing an image may result in non-proportional scaling. When cropping, fitting, or filling, you must provide both width and height such as `600x400`.
format
The format of the resulting image. Valid options include `bmp`, `gif`, `jpeg`, `png`, `tiff`, or `webp`. This defaults to the format of the source image.
hint
The encoding preset used when processing WebP images, equivalent to the `-preset` flag for the [`cwebp`](https://developers.google.com/speed/webp/docs/cwebp)
CLI. Valid options include `drawing`, `icon`, `photo`, `picture`, or `text`. This defaults to the [`hint`](https://gohugo.io/configuration/imaging/#hint)
parameter in your project configuration.
| Value | Example |
| --- | --- |
| `drawing` | Hand or line drawing with high-contrast details |
| `icon` | Small colorful image |
| `photo` | Outdoor photograph with natural lighting |
| `picture` | Indoor photograph such as a portrait |
| `text` | Image that is primarily text |
quality
The visual fidelity of the image, applicable to JPEG and WebP formats when using `lossy` compression. The format is `qQUALITY` where `QUALITY` is a whole number between `1` and `100`, inclusive. Lower numbers prioritize smaller file size, while higher numbers prioritize visual clarity. This defaults to the [`quality`](https://gohugo.io/configuration/imaging/#quality)
parameter in your project configuration.
resampling filter
The algorithm used to calculate new pixels when resizing, fitting, or filling an image. Common options include `box`, `lanczos`, `catmullRom`, `mitchellNetravali`, `linear`, or `nearestNeighbor`. This defaults to the [`resampleFilter`](https://gohugo.io/configuration/imaging/#resamplefilter)
parameter in your project configuration.
| Filter | Description |
| --- | --- |
| `box` | Simple and fast averaging filter appropriate for downscaling |
| `lanczos` | High-quality resampling filter for photographic images yielding sharp results |
| `catmullRom` | Sharp cubic filter that is faster than the Lanczos filter while providing similar results |
| `mitchellNetravali` | Cubic filter that produces smoother results with less ringing artifacts than CatmullRom |
| `linear` | Bilinear resampling filter, produces smooth output, faster than cubic filters |
| `nearestNeighbor` | Fastest resampling filter, no antialiasing |
Refer to the [source documentation](https://github.com/disintegration/imaging#image-resizing)
for a complete list of available resampling filters. If you wish to improve image quality at the expense of performance, you may wish to experiment with the alternative filters.
rotation
The number of whole degrees to rotate an image counter-clockwise. The format is `rDEGREES` where `DEGREES` is a whole number. Hugo performs rotation before any other transformations, so your [target dimensions](https://gohugo.io/methods/resource/fill/#dimensions)
and any [anchor](https://gohugo.io/methods/resource/fill/#anchor)
should refer to the image orientation after rotation. Use `r90`, `r180`, or `r270` for orthogonal rotations, or arbitrary angles such as `r45`. To rotate clockwise, use a negative number such as `r-45`. To automatically rotate an image based on its Exif orientation tag, use the [`images.AutoOrient`](https://gohugo.io/functions/images/autoorient/)
filter instead of manual rotation.
Rotating by non-orthogonal values increases the image extents to fit the rotated corners. For formats supporting alpha channels such as PNG or WebP, this resulting empty space is transparent by default. If the target format does not support transparency such as JPEG, or if you explicitly specify a [background color](https://gohugo.io/methods/resource/fill/#background-color)
in the processing specification, the space is filled. If a color is required but not specified in the processing string, it defaults to the [`bgColor`](https://gohugo.io/configuration/imaging/#bgcolor)
parameter in your project configuration.
Example
-------
{{ with resources.Get "images/original.jpg" }}
{{ with .Fill "500x200 TopRight" }}
{{ end }}
{{ end }}
Original

Processed

* * *
Last updated: February 27, 2026 : [content: Miscellaneous udpates for v0.157.0 (35da1aa3c)](https://github.com/gohugoio/hugoDocs/commit/35da1aa3c2fe3b54bdb57df1a308533844af9df5)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/resource/Fill.md)
---
# Fit
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Applicable to images, returns a new image resource downscaled to fit according to the given processing specification.
Syntax
RESOURCE.Fit SPECIFICATION
Returns
images.ImageResource
Use this method with [global resources](https://gohugo.io/quick-reference/glossary/#global-resource)
, [page resources](https://gohugo.io/quick-reference/glossary/#page-resource)
, or [remote resources](https://gohugo.io/quick-reference/glossary/#remote-resource)
.
The `Fit` method returns a new resource from a [processable image](https://gohugo.io/quick-reference/glossary/#processable-image)
according to the given [processing specification](https://gohugo.io/methods/resource/fit/#processing-specification)
.
Use the [`reflect.IsImageResourceProcessable`](https://gohugo.io/functions/reflect/isimageresourceprocessable/)
function to verify that an image can be processed.
Usage
-----
When fitting, you must provide both width and height (such as `300x175`) within the specification. `Fit` maintains the original aspect ratio by downscaling the image until it fits within the specified dimensions. Unlike [`Fill`](https://gohugo.io/methods/resource/fill/)
or [`Resize`](https://gohugo.io/methods/resource/resize/)
, this method will never upscale an image; if the source image is smaller than the target dimensions, the dimensions of the resulting image are the same as the original.
{{ with resources.Get "images/original.jpg" }}
{{ with .Fit "300x175" }}
{{ end }}
{{ end }}
In the example above, `"300x175"` is the processing specification.
Processing specification
------------------------
The processing specification is a space-delimited, case-insensitive list containing one or more of the following options in any sequence:
action
Specify one of `crop`, `fill`, `fit`, or `resize`. This is applicable to the [`Process`](https://gohugo.io/methods/resource/process/)
method and the [`images.Process`](https://gohugo.io/functions/images/process/)
filter. If you specify an action, you must also provide dimensions.
anchor
The focal point used when cropping or filling an image. Valid options include `TopLeft`, `Top`, `TopRight`, `Left`, `Center`, `Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`. The `Smart` option utilizes the [`muesli/smartcrop`](https://github.com/muesli/smartcrop)
package to identify the most interesting area of the image. This defaults to the [`anchor`](https://gohugo.io/configuration/imaging/#anchor)
parameter in your project configuration.
background color
The background color used when converting transparent images to formats that do not support transparency, such as PNG to JPEG. This color also fills the empty space created when rotating an image by a non-orthogonal angle if the space is not transparent and a background color is not specified in the processing specification. The value must be an RGB [hexadecimal color](https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color)
. This defaults to the [`bgColor`](https://gohugo.io/configuration/imaging/#bgcolor)
parameter in your project configuration.
compression
[New in v0.153.5](https://github.com/gohugoio/hugo/releases/tag/v0.153.5)
The encoding strategy used for the image. Options are `lossy` or `lossless`. Note that `lossless` is only supported by the WebP format. This defaults to the [`compression`](https://gohugo.io/configuration/imaging/#compression)
parameter in your project configuration.
dimensions
The dimensions of the resulting image, in pixels. The format is `WIDTHxHEIGHT` where `WIDTH` and `HEIGHT` are whole numbers. When resizing an image, you may specify only the width (such as `600x`) or only the height (such as `x400`) for proportional scaling. Specifying both width and height when resizing an image may result in non-proportional scaling. When cropping, fitting, or filling, you must provide both width and height such as `600x400`.
format
The format of the resulting image. Valid options include `bmp`, `gif`, `jpeg`, `png`, `tiff`, or `webp`. This defaults to the format of the source image.
hint
The encoding preset used when processing WebP images, equivalent to the `-preset` flag for the [`cwebp`](https://developers.google.com/speed/webp/docs/cwebp)
CLI. Valid options include `drawing`, `icon`, `photo`, `picture`, or `text`. This defaults to the [`hint`](https://gohugo.io/configuration/imaging/#hint)
parameter in your project configuration.
| Value | Example |
| --- | --- |
| `drawing` | Hand or line drawing with high-contrast details |
| `icon` | Small colorful image |
| `photo` | Outdoor photograph with natural lighting |
| `picture` | Indoor photograph such as a portrait |
| `text` | Image that is primarily text |
quality
The visual fidelity of the image, applicable to JPEG and WebP formats when using `lossy` compression. The format is `qQUALITY` where `QUALITY` is a whole number between `1` and `100`, inclusive. Lower numbers prioritize smaller file size, while higher numbers prioritize visual clarity. This defaults to the [`quality`](https://gohugo.io/configuration/imaging/#quality)
parameter in your project configuration.
resampling filter
The algorithm used to calculate new pixels when resizing, fitting, or filling an image. Common options include `box`, `lanczos`, `catmullRom`, `mitchellNetravali`, `linear`, or `nearestNeighbor`. This defaults to the [`resampleFilter`](https://gohugo.io/configuration/imaging/#resamplefilter)
parameter in your project configuration.
| Filter | Description |
| --- | --- |
| `box` | Simple and fast averaging filter appropriate for downscaling |
| `lanczos` | High-quality resampling filter for photographic images yielding sharp results |
| `catmullRom` | Sharp cubic filter that is faster than the Lanczos filter while providing similar results |
| `mitchellNetravali` | Cubic filter that produces smoother results with less ringing artifacts than CatmullRom |
| `linear` | Bilinear resampling filter, produces smooth output, faster than cubic filters |
| `nearestNeighbor` | Fastest resampling filter, no antialiasing |
Refer to the [source documentation](https://github.com/disintegration/imaging#image-resizing)
for a complete list of available resampling filters. If you wish to improve image quality at the expense of performance, you may wish to experiment with the alternative filters.
rotation
The number of whole degrees to rotate an image counter-clockwise. The format is `rDEGREES` where `DEGREES` is a whole number. Hugo performs rotation before any other transformations, so your [target dimensions](https://gohugo.io/methods/resource/fit/#dimensions)
and any [anchor](https://gohugo.io/methods/resource/fit/#anchor)
should refer to the image orientation after rotation. Use `r90`, `r180`, or `r270` for orthogonal rotations, or arbitrary angles such as `r45`. To rotate clockwise, use a negative number such as `r-45`. To automatically rotate an image based on its Exif orientation tag, use the [`images.AutoOrient`](https://gohugo.io/functions/images/autoorient/)
filter instead of manual rotation.
Rotating by non-orthogonal values increases the image extents to fit the rotated corners. For formats supporting alpha channels such as PNG or WebP, this resulting empty space is transparent by default. If the target format does not support transparency such as JPEG, or if you explicitly specify a [background color](https://gohugo.io/methods/resource/fit/#background-color)
in the processing specification, the space is filled. If a color is required but not specified in the processing string, it defaults to the [`bgColor`](https://gohugo.io/configuration/imaging/#bgcolor)
parameter in your project configuration.
Example
-------
{{ with resources.Get "images/original.jpg" }}
{{ with .Fit "300x175" }}
{{ end }}
{{ end }}
Original

Processed

* * *
Last updated: February 27, 2026 : [content: Miscellaneous udpates for v0.157.0 (35da1aa3c)](https://github.com/gohugoio/hugoDocs/commit/35da1aa3c2fe3b54bdb57df1a308533844af9df5)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/resource/Fit.md)
---
# GroupBy
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection grouped by the given field in ascending order.
Syntax
PAGES.GroupBy FIELD \[SORT\]
Returns
page.PagesGroup
For the optional sort order, specify either `asc` for ascending order, or `desc` for descending order.
{{ range .Pages.GroupBy "Section" }}
{{ end }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/GroupBy.md)
---
# GroupByParam
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection grouped by the given parameter in ascending order.
Syntax
PAGES.GroupByParam PARAM \[SORT\]
Returns
page.PagesGroup
For the optional sort order, specify either `asc` for ascending order, or `desc` for descending order.
{{ range .Pages.GroupByParam "color" }}
{{ end }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/GroupByParam.md)
---
# GroupByDate
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection grouped by date in descending order.
Syntax
PAGES.GroupByDate LAYOUT \[SORT\]
Returns
page.PagesGroup
When grouping by date, the value is determined by your [project configuration](https://gohugo.io/configuration/front-matter/#dates)
, defaulting to the `date` field in front matter.
The [layout string](https://gohugo.io/methods/pages/groupbydate/#layout-string)
has the same format as the layout string for the [`time.Format`](https://gohugo.io/functions/time/format/)
function. The resulting group key is [localized](https://gohugo.io/quick-reference/glossary/#localization)
for language and region.
For the optional sort order, specify either `asc` for ascending order, or `desc` for descending order.
To group content by year and month:
{{ range .Pages.GroupByDate "January 2006" }}
{{ end }}
The pages within each group will also be sorted by date, either ascending or descending depending on the grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
{{ range .Pages.GroupByDate "January 2006" }}
{{ end }}
Layout string
-------------
Format a `time.Time` value based on [Go’s reference time](https://pkg.go.dev/time#pkg-constants)
:
Mon Jan 2 15:04:05 MST 2006
Create a layout string using these components:
| Description | Valid components |
| --- | --- |
| Year | `"2006" "06"` |
| Month | `"Jan" "January" "01" "1"` |
| Day of the week | `"Mon" "Monday"` |
| Day of the month | `"2" "_2" "02"` |
| Day of the year | `"__2" "002"` |
| Hour | `"15" "3" "03"` |
| Minute | `"4" "04"` |
| Second | `"5" "05"` |
| AM/PM mark | `"PM"` |
| Time zone offsets | `"-0700" "-07:00" "-07" "-070000" "-07:00:00"` |
Replace the sign in the layout string with a Z to print Z instead of an offset for the UTC zone.
| Description | Valid components |
| --- | --- |
| Time zone offsets | `"Z0700" "Z07:00" "Z07" "Z070000" "Z07:00:00"` |
{{ $t := "2023-01-27T23:44:58-08:00" }}
{{ $t = time.AsTime $t }}
{{ $t = $t.Format "Jan 02, 2006 3:04 PM Z07:00" }}
{{ $t }} → Jan 27, 2023 11:44 PM -08:00
Strings such as `PST` and `CET` are not time zones. They are time zone _abbreviations_.
Strings such as `-07:00` and `+01:00` are not time zones. They are time zone _offsets_.
A time zone is a geographic area with the same local time. For example, the time zone abbreviated by `PST` and `PDT` (depending on Daylight Savings Time) is `America/Los_Angeles`.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/GroupByDate.md)
---
# GroupByLastmod
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection grouped by last modification date in descending order.
Syntax
PAGES.GroupByLastmod LAYOUT \[SORT\]
Returns
page.PagesGroup
When grouping by last modification date, the value is determined by your [project configuration](https://gohugo.io/configuration/front-matter/#dates)
, defaulting to the `lastmod` field in front matter.
The [layout string](https://gohugo.io/methods/pages/groupbylastmod/#layout-string)
has the same format as the layout string for the [`time.Format`](https://gohugo.io/functions/time/format/)
function. The resulting group key is [localized](https://gohugo.io/quick-reference/glossary/#localization)
for language and region.
For the optional sort order, specify either `asc` for ascending order, or `desc` for descending order.
To group content by year and month:
{{ range .Pages.GroupByLastmod "January 2006" }}
{{ end }}
The pages within each group will also be sorted by last modification date, either ascending or descending depending on your grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
{{ range .Pages.GroupByLastmod "January 2006" }}
{{ end }}
Layout string
-------------
Format a `time.Time` value based on [Go’s reference time](https://pkg.go.dev/time#pkg-constants)
:
Mon Jan 2 15:04:05 MST 2006
Create a layout string using these components:
| Description | Valid components |
| --- | --- |
| Year | `"2006" "06"` |
| Month | `"Jan" "January" "01" "1"` |
| Day of the week | `"Mon" "Monday"` |
| Day of the month | `"2" "_2" "02"` |
| Day of the year | `"__2" "002"` |
| Hour | `"15" "3" "03"` |
| Minute | `"4" "04"` |
| Second | `"5" "05"` |
| AM/PM mark | `"PM"` |
| Time zone offsets | `"-0700" "-07:00" "-07" "-070000" "-07:00:00"` |
Replace the sign in the layout string with a Z to print Z instead of an offset for the UTC zone.
| Description | Valid components |
| --- | --- |
| Time zone offsets | `"Z0700" "Z07:00" "Z07" "Z070000" "Z07:00:00"` |
{{ $t := "2023-01-27T23:44:58-08:00" }}
{{ $t = time.AsTime $t }}
{{ $t = $t.Format "Jan 02, 2006 3:04 PM Z07:00" }}
{{ $t }} → Jan 27, 2023 11:44 PM -08:00
Strings such as `PST` and `CET` are not time zones. They are time zone _abbreviations_.
Strings such as `-07:00` and `+01:00` are not time zones. They are time zone _offsets_.
A time zone is a geographic area with the same local time. For example, the time zone abbreviated by `PST` and `PDT` (depending on Daylight Savings Time) is `America/Los_Angeles`.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/GroupByLastmod.md)
---
# GroupByExpiryDate
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection grouped by expiration date in descending order.
Syntax
PAGES.GroupByExpiryDate LAYOUT \[SORT\]
Returns
page.PagesGroup
When grouping by expiration date, the value is determined by your [project configuration](https://gohugo.io/configuration/front-matter/#dates)
, defaulting to the `expiryDate` field in front matter.
The [layout string](https://gohugo.io/methods/pages/groupbyexpirydate/#layout-string)
has the same format as the layout string for the [`time.Format`](https://gohugo.io/functions/time/format/)
function. The resulting group key is [localized](https://gohugo.io/quick-reference/glossary/#localization)
for language and region.
For the optional sort order, specify either `asc` for ascending order, or `desc` for descending order.
To group content by year and month:
{{ range .Pages.GroupByExpiryDate "January 2006" }}
{{ end }}
The pages within each group will also be sorted by expiration date, either ascending or descending depending on your grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
{{ range .Pages.GroupByExpiryDate "January 2006" }}
{{ end }}
Layout string
-------------
Format a `time.Time` value based on [Go’s reference time](https://pkg.go.dev/time#pkg-constants)
:
Mon Jan 2 15:04:05 MST 2006
Create a layout string using these components:
| Description | Valid components |
| --- | --- |
| Year | `"2006" "06"` |
| Month | `"Jan" "January" "01" "1"` |
| Day of the week | `"Mon" "Monday"` |
| Day of the month | `"2" "_2" "02"` |
| Day of the year | `"__2" "002"` |
| Hour | `"15" "3" "03"` |
| Minute | `"4" "04"` |
| Second | `"5" "05"` |
| AM/PM mark | `"PM"` |
| Time zone offsets | `"-0700" "-07:00" "-07" "-070000" "-07:00:00"` |
Replace the sign in the layout string with a Z to print Z instead of an offset for the UTC zone.
| Description | Valid components |
| --- | --- |
| Time zone offsets | `"Z0700" "Z07:00" "Z07" "Z070000" "Z07:00:00"` |
{{ $t := "2023-01-27T23:44:58-08:00" }}
{{ $t = time.AsTime $t }}
{{ $t = $t.Format "Jan 02, 2006 3:04 PM Z07:00" }}
{{ $t }} → Jan 27, 2023 11:44 PM -08:00
Strings such as `PST` and `CET` are not time zones. They are time zone _abbreviations_.
Strings such as `-07:00` and `+01:00` are not time zones. They are time zone _offsets_.
A time zone is a geographic area with the same local time. For example, the time zone abbreviated by `PST` and `PDT` (depending on Daylight Savings Time) is `America/Los_Angeles`.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/GroupByExpiryDate.md)
---
# GroupByPublishDate
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection grouped by publish date in descending order.
Syntax
PAGES.GroupByPublishDate LAYOUT \[SORT\]
Returns
page.PagesGroup
When grouping by publish date, the value is determined by your [project configuration](https://gohugo.io/configuration/front-matter/#dates)
, defaulting to the `publishDate` field in front matter.
The [layout string](https://gohugo.io/methods/pages/groupbypublishdate/#layout-string)
has the same format as the layout string for the [`time.Format`](https://gohugo.io/functions/time/format/)
function. The resulting group key is [localized](https://gohugo.io/quick-reference/glossary/#localization)
for language and region.
For the optional sort order, specify either `asc` for ascending order, or `desc` for descending order.
To group content by year and month:
{{ range .Pages.GroupByPublishDate "January 2006" }}
{{ end }}
The pages within each group will also be sorted by publish date, either ascending or descending depending on your grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
{{ range .Pages.GroupByPublishDate "January 2006" }}
{{ end }}
Layout string
-------------
Format a `time.Time` value based on [Go’s reference time](https://pkg.go.dev/time#pkg-constants)
:
Mon Jan 2 15:04:05 MST 2006
Create a layout string using these components:
| Description | Valid components |
| --- | --- |
| Year | `"2006" "06"` |
| Month | `"Jan" "January" "01" "1"` |
| Day of the week | `"Mon" "Monday"` |
| Day of the month | `"2" "_2" "02"` |
| Day of the year | `"__2" "002"` |
| Hour | `"15" "3" "03"` |
| Minute | `"4" "04"` |
| Second | `"5" "05"` |
| AM/PM mark | `"PM"` |
| Time zone offsets | `"-0700" "-07:00" "-07" "-070000" "-07:00:00"` |
Replace the sign in the layout string with a Z to print Z instead of an offset for the UTC zone.
| Description | Valid components |
| --- | --- |
| Time zone offsets | `"Z0700" "Z07:00" "Z07" "Z070000" "Z07:00:00"` |
{{ $t := "2023-01-27T23:44:58-08:00" }}
{{ $t = time.AsTime $t }}
{{ $t = $t.Format "Jan 02, 2006 3:04 PM Z07:00" }}
{{ $t }} → Jan 27, 2023 11:44 PM -08:00
Strings such as `PST` and `CET` are not time zones. They are time zone _abbreviations_.
Strings such as `-07:00` and `+01:00` are not time zones. They are time zone _offsets_.
A time zone is a geographic area with the same local time. For example, the time zone abbreviated by `PST` and `PDT` (depending on Daylight Savings Time) is `America/Los_Angeles`.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/GroupByPublishDate.md)
---
# GroupByParamDate
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the given page collection grouped by the given date parameter in descending order.
Syntax
PAGES.GroupByParamDate PARAM LAYOUT \[SORT\]
Returns
page.PagesGroup
The [layout string](https://gohugo.io/methods/pages/groupbyparamdate/#layout-string)
has the same format as the layout string for the [`time.Format`](https://gohugo.io/functions/time/format/)
function. The resulting group key is [localized](https://gohugo.io/quick-reference/glossary/#localization)
for language and region.
For the optional sort order, specify either `asc` for ascending order, or `desc` for descending order.
To group content by year and month:
{{ range .Pages.GroupByParamDate "eventDate" "January 2006" }}
{{ end }}
The pages within each group will also be sorted by the parameter date, either ascending or descending depending on your grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
{{ range .Pages.GroupByParamDate "eventDate" "January 2006" }}
{{ end }}
Layout string
-------------
Format a `time.Time` value based on [Go’s reference time](https://pkg.go.dev/time#pkg-constants)
:
Mon Jan 2 15:04:05 MST 2006
Create a layout string using these components:
| Description | Valid components |
| --- | --- |
| Year | `"2006" "06"` |
| Month | `"Jan" "January" "01" "1"` |
| Day of the week | `"Mon" "Monday"` |
| Day of the month | `"2" "_2" "02"` |
| Day of the year | `"__2" "002"` |
| Hour | `"15" "3" "03"` |
| Minute | `"4" "04"` |
| Second | `"5" "05"` |
| AM/PM mark | `"PM"` |
| Time zone offsets | `"-0700" "-07:00" "-07" "-070000" "-07:00:00"` |
Replace the sign in the layout string with a Z to print Z instead of an offset for the UTC zone.
| Description | Valid components |
| --- | --- |
| Time zone offsets | `"Z0700" "Z07:00" "Z07" "Z070000" "Z07:00:00"` |
{{ $t := "2023-01-27T23:44:58-08:00" }}
{{ $t = time.AsTime $t }}
{{ $t = $t.Format "Jan 02, 2006 3:04 PM Z07:00" }}
{{ $t }} → Jan 27, 2023 11:44 PM -08:00
Strings such as `PST` and `CET` are not time zones. They are time zone _abbreviations_.
Strings such as `-07:00` and `+01:00` are not time zones. They are time zone _offsets_.
A time zone is a geographic area with the same local time. For example, the time zone abbreviated by `PST` and `PDT` (depending on Daylight Savings Time) is `America/Los_Angeles`.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/pages/GroupByParamDate.md)
---
# Configure deployment
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Configure deployments to Amazon S3, Azure Blob Storage, or Google Cloud Storage.
This configuration is only relevant when running `hugo deploy`. See [details](https://gohugo.io/host-and-deploy/deploy-with-hugo-deploy/)
.
Top-level options
-----------------
These settings control the overall behavior of the deployment process. This is the default configuration:
deployment:
confirm: false
dryRun: false
force: false
invalidateCDN: true
matchers: null
maxDeletes: 256
order: null
target: ''
targets: null
workers: 10
[deployment]
confirm = false
dryRun = false
force = false
invalidateCDN = true
maxDeletes = 256
target = ''
workers = 10
{
"deployment": {
"confirm": false,
"dryRun": false,
"force": false,
"invalidateCDN": true,
"matchers": null,
"maxDeletes": 256,
"order": null,
"target": "",
"targets": null,
"workers": 10
}
}
confirm
(`bool`) Whether to prompt for confirmation before deploying. Default is `false`.
dryRun
(`bool`) Whether to simulate the deployment without any remote changes. Default is `false`.
force
(`bool`) Whether to re-upload all files. Default is `false`.
invalidateCDN
(`bool`) Whether to invalidate the CDN cache listed in the deployment target. Default is `true`.
maxDeletes
(`int`) The maximum number of files to delete, or `-1` to disable. Default is `256`.
matchers
(`[]*Matcher`) A slice of [matchers](https://gohugo.io/configuration/deployment/#matchers-1)
.
order
(`[]string`) An ordered slice of [regular expressions](https://gohugo.io/quick-reference/glossary/#regular-expression)
that determines upload priority (left to right). Files not matching any expression are uploaded last in an arbitrary order.
target
(`string`) The target deployment [`name`](https://gohugo.io/configuration/deployment/#name)
. Defaults to the first target.
targets
(`[]*Target`) A slice of [targets](https://gohugo.io/configuration/deployment/#targets-1)
.
workers
(`int`) The number of concurrent workers to use when uploading files. Default is `10`.
Targets
-------
A target represents a deployment target such as “staging” or “production”.
cloudFrontDistributionID
(`string`) The CloudFront Distribution ID, applicable if you are using the Amazon Web Services CloudFront CDN. Hugo will invalidate the CDN when deploying this target.
exclude
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching files to exclude when deploying to this target. Local files failing the include/exclude filters are not uploaded, and remote files failing these filters are not deleted.
googleCloudCDNOrigin
(`string`) The Google Cloud project and CDN origin to invalidate when deploying this target, specified as `/`.
include
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching files to include when deploying to this target. Local files failing the include/exclude filters are not uploaded, and remote files failing these filters are not deleted.
name
(`string`) An arbitrary name for this target.
stripIndexHTML
(`bool`) Whether to map files named `/index.html` to `` on the remote (except for the root `index.html`). This is useful for key-value cloud storage (e.g., Amazon S3, Google Cloud Storage, Azure Blob Storage) to align canonical URLs with object keys. Default is `false`.
url
(`string`) The [destination URL](https://gohugo.io/configuration/deployment/#destination-urls)
for deployment.
Matchers
--------
A Matcher represents a configuration to be applied to files whose paths match the specified pattern.
cacheControl
(`string`) The caching attributes to use when serving the blob. See [details](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control)
.
contentEncoding
(`string`) The encoding used for the blob’s content, if any. See [details](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding)
.
contentType
(`string`) The media type of the blob being written. See [details](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type)
.
force
(`bool`) Whether matching files should be re-uploaded. Useful when other route-determined metadata (e.g., `contentType`) has changed. Default is `false`.
gzip
(`bool`) Whether the file should be gzipped before upload. If so, the `ContentEncoding` field will automatically be set to `gzip`. Default is `false`.
pattern
(`string`) A [regular expression](https://gohugo.io/quick-reference/glossary/#regular-expression)
used to match paths. Paths are converted to use forward slashes (`/`) before matching.
Destination URLs
----------------
| Service | URL example |
| --- | --- |
| Amazon Simple Storage Service (S3) | `s3://my-bucket?region=us-west-1` |
| Azure Blob Storage | `azblob://my-container` |
| Google Cloud Storage (GCS) | `gs://my-bucket` |
With Google Cloud Storage you can target a subdirectory:
gs://my-bucket?prefix=a/subdirectory
You can also to deploy to storage servers compatible with Amazon S3 such as:
* [Ceph](https://ceph.com/)
* [MinIO](https://www.minio.io/)
* [SeaweedFS](https://github.com/chrislusf/seaweedfs)
For example, the `url` for a MinIO deployment target might resemble this:
s3://my-bucket?endpoint=https://my.minio.instance&awssdk=v2&use_path_style=true&disable_https=false
Example
-------
deployment:
matchers:
- cacheControl: max-age=31536000, no-transform, public
gzip: true
pattern: '^.+\.(js|css|svg|ttf)$'
- cacheControl: max-age=31536000, no-transform, public
gzip: false
pattern: '^.+\.(png|jpg)$'
- contentType: application/xml
gzip: true
pattern: '^sitemap\.xml$'
- gzip: true
pattern: '^.+\.(html|xml|json)$'
order:
- .jpg$
- .gif$
targets:
- cloudFrontDistributionID: E1234567890ABCDEF0
exclude: '**.{heic,psd}'
name: production
url: s3://my_production_bucket?region=us-west-1
- exclude: '**.{heic,psd}'
name: staging
url: s3://my_staging_bucket?region=us-west-1
[deployment]
order = ['.jpg$', '.gif$']
[[deployment.matchers]]
cacheControl = 'max-age=31536000, no-transform, public'
gzip = true
pattern = '^.+\.(js|css|svg|ttf)$'
[[deployment.matchers]]
cacheControl = 'max-age=31536000, no-transform, public'
gzip = false
pattern = '^.+\.(png|jpg)$'
[[deployment.matchers]]
contentType = 'application/xml'
gzip = true
pattern = '^sitemap\.xml$'
[[deployment.matchers]]
gzip = true
pattern = '^.+\.(html|xml|json)$'
[[deployment.targets]]
cloudFrontDistributionID = 'E1234567890ABCDEF0'
exclude = '**.{heic,psd}'
name = 'production'
url = 's3://my_production_bucket?region=us-west-1'
[[deployment.targets]]
exclude = '**.{heic,psd}'
name = 'staging'
url = 's3://my_staging_bucket?region=us-west-1'
{
"deployment": {
"matchers": [\
{\
"cacheControl": "max-age=31536000, no-transform, public",\
"gzip": true,\
"pattern": "^.+\\.(js|css|svg|ttf)$"\
},\
{\
"cacheControl": "max-age=31536000, no-transform, public",\
"gzip": false,\
"pattern": "^.+\\.(png|jpg)$"\
},\
{\
"contentType": "application/xml",\
"gzip": true,\
"pattern": "^sitemap\\.xml$"\
},\
{\
"gzip": true,\
"pattern": "^.+\\.(html|xml|json)$"\
}\
],
"order": [\
".jpg$",\
".gif$"\
],
"targets": [\
{\
"cloudFrontDistributionID": "E1234567890ABCDEF0",\
"exclude": "**.{heic,psd}",\
"name": "production",\
"url": "s3://my_production_bucket?region=us-west-1"\
},\
{\
"exclude": "**.{heic,psd}",\
"name": "staging",\
"url": "s3://my_staging_bucket?region=us-west-1"\
}\
]
}
}
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/configuration/deployment.md)
---
# Format
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a textual representation of the time.Time value formatted according to the layout string.
Syntax
TIME.Format LAYOUT
Returns
string
{{ $t := "2023-01-27T23:44:58-08:00" }}
{{ $t = time.AsTime $t }}
{{ $format := "2 Jan 2006" }}
{{ $t.Format $format }} → 27 Jan 2023
To [localize](https://gohugo.io/quick-reference/glossary/#localization)
the return value, use the [`time.Format`](https://gohugo.io/functions/time/format/)
function instead.
Use the `Format` method with any `time.Time` value, including the four predefined front matter dates:
{{ $format := "2 Jan 2006" }}
{{ .Date.Format $format }}
{{ .PublishDate.Format $format }}
{{ .ExpiryDate.Format $format }}
{{ .Lastmod.Format $format }}
Use the [`time.Format`](https://gohugo.io/functions/time/format/)
function to format string representations of dates, and to format raw TOML dates that exclude time and time zone offset.
Layout string
-------------
Format a `time.Time` value based on [Go’s reference time](https://pkg.go.dev/time#pkg-constants)
:
Mon Jan 2 15:04:05 MST 2006
Create a layout string using these components:
| Description | Valid components |
| --- | --- |
| Year | `"2006" "06"` |
| Month | `"Jan" "January" "01" "1"` |
| Day of the week | `"Mon" "Monday"` |
| Day of the month | `"2" "_2" "02"` |
| Day of the year | `"__2" "002"` |
| Hour | `"15" "3" "03"` |
| Minute | `"4" "04"` |
| Second | `"5" "05"` |
| AM/PM mark | `"PM"` |
| Time zone offsets | `"-0700" "-07:00" "-07" "-070000" "-07:00:00"` |
Replace the sign in the layout string with a Z to print Z instead of an offset for the UTC zone.
| Description | Valid components |
| --- | --- |
| Time zone offsets | `"Z0700" "Z07:00" "Z07" "Z070000" "Z07:00:00"` |
{{ $t := "2023-01-27T23:44:58-08:00" }}
{{ $t = time.AsTime $t }}
{{ $t = $t.Format "Jan 02, 2006 3:04 PM Z07:00" }}
{{ $t }} → Jan 27, 2023 11:44 PM -08:00
Strings such as `PST` and `CET` are not time zones. They are time zone _abbreviations_.
Strings such as `-07:00` and `+01:00` are not time zones. They are time zone _offsets_.
A time zone is a geographic area with the same local time. For example, the time zone abbreviated by `PST` and `PDT` (depending on Daylight Savings Time) is `America/Los_Angeles`.
Examples
--------
Given this front matter:
---
date: 2023-01-27T23:44:58-08:00
title: About time
---
+++
date = 2023-01-27T23:44:58-08:00
title = 'About time'
+++
{
"date": "2023-01-27T23:44:58-08:00",
"title": "About time"
}
The examples below were rendered in the `America/Los_Angeles` time zone:
| Format string | Result |
| --- | --- |
| `Monday, January 2, 2006` | `Friday, January 27, 2023` |
| `Mon Jan 2 2006` | `Fri Jan 27 2023` |
| `January 2006` | `January 2023` |
| `2006-01-02` | `2023-01-27` |
| `Monday` | `Friday` |
| `02 Jan 06 15:04 MST` | `27 Jan 23 23:44 PST` |
| `Mon, 02 Jan 2006 15:04:05 MST` | `Fri, 27 Jan 2023 23:44:58 PST` |
| `Mon, 02 Jan 2006 15:04:05 -0700` | `Fri, 27 Jan 2023 23:44:58 -0800` |
UTC and local time
------------------
Convert and format any `time.Time` value to either Coordinated Universal Time (UTC) or local time.
{{ $t := "2023-01-27T23:44:58-08:00" }}
{{ $t = time.AsTime $t }}
{{ $format := "2 Jan 2006 3:04:05 PM MST" }}
{{ $t.UTC.Format $format }} → 28 Jan 2023 7:44:58 AM UTC
{{ $t.Local.Format $format }} → 27 Jan 2023 11:44:58 PM PST
Ordinal representation
----------------------
Use the [`humanize`](https://gohugo.io/functions/inflect/humanize/)
function to render the day of the month as an ordinal number:
{{ $t := "2023-01-27T23:44:58-08:00" }}
{{ $t = time.AsTime $t }}
{{ humanize $t.Day }} of {{ $t.Format "January 2006" }} → 27th of January 2023
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/time/Format.md)
---
# GetPage
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a Page object from the given path.
Syntax
SITE.GetPage PATH
Returns
page.Page
The `GetPage` method is also available on `Page` objects, allowing you to specify a path relative to the current page. See [details](https://gohugo.io/methods/page/getpage/)
.
When using the `GetPage` method on a `Site` object, specify a path relative to the `content` directory.
If Hugo cannot resolve the path to a page, the method returns nil.
Consider this content structure:
content/
├── works/
│ ├── paintings/
│ │ ├── _index.md
│ │ ├── starry-night.md
│ │ └── the-mona-lisa.md
│ ├── sculptures/
│ │ ├── _index.md
│ │ ├── david.md
│ │ └── the-thinker.md
│ └── _index.md
└── _index.md
This _home_ template:
layouts/home.html
{{ with .Site.GetPage "/works/paintings" }}
{{ range .Pages }}
{{ .Title }} by {{ .Params.artist }}
{{ end }}
{{ end }}
Is rendered to:
Starry Night by Vincent van Gogh
The Mona Lisa by Leonardo da Vinci
To get a regular page instead of a section page:
layouts/home.html
{{ with .Site.GetPage "/works/paintings/starry-night" }}
{{ .Title }} → Starry Night
{{ .Params.artist }} → Vincent van Gogh
{{ end }}
Multilingual projects
---------------------
With multilingual projects, the `GetPage` method on a `Site` object resolves the given path to a page in the current language.
To get a page from a different language, query the `Sites` object:
{{ with where hugo.Sites "Language.Lang" "eq" "de" }}
{{ with index . 0 }}
{{ with .GetPage "/works/paintings/starry-night" }}
{{ .Title }} → Sternenklare Nacht
{{ end }}
{{ end }}
{{ end }}
Page bundles
------------
Consider this content structure:
content/
├── headless/
│ ├── a.jpg
│ ├── b.jpg
│ ├── c.jpg
│ └── index.md <-- front matter: headless = true
└── _index.md
In the _home_ template, use the `GetPage` method on a `Site` object to render all the images in the headless [page bundle](https://gohugo.io/quick-reference/glossary/#page-bundle)
:
layouts/home.html
{{ with .Site.GetPage "/headless" }}
{{ range .Resources.ByType "image" }}
{{ end }}
{{ end }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/site/GetPage.md)
---
# Configure front matter
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Configure front matter.
Dates
-----
There are four methods on a `Page` object that return a date.
| Method | Description |
| --- | --- |
| [`Date`](https://gohugo.io/methods/page/date/) | Returns the date of the given page. |
| [`ExpiryDate`](https://gohugo.io/methods/page/expirydate/) | Returns the expiry date of the given page. |
| [`Lastmod`](https://gohugo.io/methods/page/lastmod/) | Returns the last modification date of the given page. |
| [`PublishDate`](https://gohugo.io/methods/page/publishdate/) | Returns the publish date of the given page. |
Hugo determines the values to return based on this configuration:
frontmatter:
date:
- date
- publishdate
- pubdate
- published
- lastmod
- modified
expiryDate:
- expirydate
- unpublishdate
lastmod:
- :git
- lastmod
- modified
- date
- publishdate
- pubdate
- published
publishDate:
- publishdate
- pubdate
- published
- date
[frontmatter]
date = ['date', 'publishdate', 'pubdate', 'published', 'lastmod', 'modified']
expiryDate = ['expirydate', 'unpublishdate']
lastmod = [':git', 'lastmod', 'modified', 'date', 'publishdate', 'pubdate', 'published']
publishDate = ['publishdate', 'pubdate', 'published', 'date']
{
"frontmatter": {
"date": [\
"date",\
"publishdate",\
"pubdate",\
"published",\
"lastmod",\
"modified"\
],
"expiryDate": [\
"expirydate",\
"unpublishdate"\
],
"lastmod": [\
":git",\
"lastmod",\
"modified",\
"date",\
"publishdate",\
"pubdate",\
"published"\
],
"publishDate": [\
"publishdate",\
"pubdate",\
"published",\
"date"\
]
}
}
The `ExpiryDate` method, for example, returns the `expirydate` value if it exists, otherwise it returns `unpublishdate`.
You can also use custom date parameters:
frontmatter:
date:
- myDate
- date
[frontmatter]
date = ['myDate', 'date']
{
"frontmatter": {
"date": [\
"myDate",\
"date"\
]
}
}
In the example above, the `Date` method returns the `myDate` value if it exists, otherwise it returns `date`.
To fall back to the default sequence of dates, use the `:default` token:
frontmatter:
date:
- myDate
- :default
[frontmatter]
date = ['myDate', ':default']
{
"frontmatter": {
"date": [\
"myDate",\
":default"\
]
}
}
In the example above, the `Date` method returns the `myDate` value if it exists, otherwise it returns the first valid date from `date`, `publishdate`, `pubdate`, `published`, `lastmod`, and `modified`.
Aliases
-------
Some of the front matter fields have aliases.
| Front matter field | Aliases |
| --- | --- |
| `expiryDate` | `unpublishdate` |
| `lastmod` | `modified` |
| `publishDate` | `pubdate`, `published` |
The default front matter configuration includes these aliases.
Tokens
------
Hugo provides the following [tokens](https://gohugo.io/quick-reference/glossary/#token)
to help you configure your front matter:
`:default`
The default ordered sequence of date fields.
`:fileModTime`
The file’s last modification timestamp.
`:filename`
Extracts the date from the file name, provided the file name begins with a date in one of the following formats:
* `YYYY-MM-DD`
* `YYYY-MM-DD-HH-MM-SS` [New in v0.148.0](https://github.com/gohugoio/hugo/releases/tag/v0.148.0)
Within the `YYYY-MM-DD-HH-MM-SS` format, the date and time values may be separated by any character including a space (e.g., `2025-02-01T14-30-00`).
Hugo resolves the extracted date to the [`timeZone`](https://gohugo.io/configuration/all/#timezone)
defined in your project configuration, falling back to the system time zone. After extracting the date, Hugo uses the remaining part of the file name to generate the page’s [`slug`](https://gohugo.io/content-management/front-matter/#slug)
, but only if you haven’t already specified a slug in the page’s front matter.
For example, if you name your file `2025-02-01-article.md`, Hugo will set the date to `2025-02-01` and the slug to `article`.
`:git`
The Git author date for the file’s last revision. To enable access to the Git author date, set [`enableGitInfo`](https://gohugo.io/configuration/all/#enablegitinfo)
to `true`.
Example
-------
Consider this project configuration:
frontmatter:
date:
- :filename
- :default
lastmod:
- lastmod
- :fileModTime
publishDate:
- :filename
- :default
[frontmatter]
date = [':filename', ':default']
lastmod = ['lastmod', ':fileModTime']
publishDate = [':filename', ':default']
{
"frontmatter": {
"date": [\
":filename",\
":default"\
],
"lastmod": [\
"lastmod",\
":fileModTime"\
],
"publishDate": [\
":filename",\
":default"\
]
}
}
To determine `date` and `publishDate`, Hugo tries to extract the value from the file name, falling back to the default ordered sequence of date fields.
To determine `lastmod`, Hugo looks for a `lastmod` field in front matter, falling back to the file’s last modification timestamp.
* * *
Last updated: February 27, 2026 : [content: Miscellaneous udpates for v0.157.0 (35da1aa3c)](https://github.com/gohugoio/hugoDocs/commit/35da1aa3c2fe3b54bdb57df1a308533844af9df5)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/configuration/front-matter.md)
---
# Diagrams
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Use fenced code blocks and Markdown render hooks to include diagrams in your content.
GoAT diagrams (ASCII)
---------------------
Hugo natively supports [GoAT](https://github.com/bep/goat)
diagrams with an [embedded code block render hook](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-codeblock-goat.html)
. This means that this code block:
```goat
. . . .--- 1 .-- 1 / 1
/ \ | | .---+ .-+ +
/ \ .---+---. .--+--. | '--- 2 | '-- 2 / \ 2
+ + | | | | ---+ ---+ +
/ \ / \ .-+-. .-+-. .+. .+. | .--- 3 | .-- 3 \ / 3
/ \ / \ | | | | | | | | '---+ '-+ +
1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4
```
Will be rendered as:
123412341234123412341234
Mermaid diagrams
----------------
Hugo does not provide a built-in template for Mermaid diagrams. Create your own using a [code block render hook](https://gohugo.io/render-hooks/code-blocks/)
:
layouts/\_markup/render-codeblock-mermaid.html
* * *
Last updated: March 6, 2026 : [content: Clarify page collection sort order (9297bb6fa)](https://github.com/gohugoio/hugoDocs/commit/9297bb6fa03c888357127a048fd4c559573b5ffb)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/AllTranslations.md)
---
# AlternativeOutputFormats
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a slice of OutputFormat objects, excluding the current output format, each representing one of the output formats enabled for the given page.
Syntax
PAGE.AlternativeOutputFormats
Returns
page.OutputFormats
An _output format_ is a collection of settings that defines how Hugo renders a file when building a site. For example, `html`, `json`, and `rss` are built-in output formats. You can create multiple output formats and control their generation based on [_page kind_](https://gohugo.io/quick-reference/glossary/#page-kind)
, or by enabling one or more output formats for specific pages.
The `AlternativeOutputFormats` method on a `Page` object returns a slice of `OutputFormat` objects, excluding the current output format, each representing one of the output formats enabled for the given page. See [details](https://gohugo.io/configuration/output-formats/)
.
For example, to generate a `link` element for each of the alternative output formats:
{{ range .AlternativeOutputFormats }}
{{ printf "" .Rel .MediaType.Type .Permalink | safeHTML }}
{{ end }}
Hugo renders this to something like:
* * *
Last updated: February 14, 2026 : [Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' (3e2f98235)](https://github.com/gohugoio/hugoDocs/commit/3e2f9823554f16b7b5a9a815b30c9c1fdbc7281b)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/AlternativeOutputFormats.md)
---
# Ancestors
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a collection of Page objects, one for each ancestor section of the given page.
Syntax
PAGE.Ancestors
Returns
page.Pages
With this content structure:
content/
├── auctions/
│ ├── 2023-11/
│ │ ├── _index.md <-- front matter: weight = 202311
│ │ ├── auction-1.md
│ │ └── auction-2.md
│ ├── 2023-12/
│ │ ├── _index.md <-- front matter: weight = 202312
│ │ ├── auction-3.md
│ │ └── auction-4.md
│ ├── _index.md <-- front matter: weight = 30
│ ├── bidding.md
│ └── payment.md
├── books/
│ ├── _index.md <-- front matter: weight = 10
│ ├── book-1.md
│ └── book-2.md
├── films/
│ ├── _index.md <-- front matter: weight = 20
│ ├── film-1.md
│ └── film-2.md
└── _index.md
And this template:
{{ range .Ancestors }}
{{ .LinkTitle }}
{{ end }}
On the November 2023 auctions page, Hugo renders:
Auctions in November 2023AuctionsHome
In the example above, notice that Hugo orders the ancestors from closest to furthest. This makes breadcrumb navigation simple:
With some CSS, the code above renders something like this, where each breadcrumb links to its page:
Home > Auctions > Auctions in November 2023 > Auction 1
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/Ancestors.md)
---
# Aliases
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the aliases defined in front matter as server-relative URLs, resolved according to the current content dimension.
Syntax
PAGE.Aliases
Returns
\[\]string
The `Aliases` method on a `Page` object returns the values defined in the [`aliases`](https://gohugo.io/content-management/front-matter/#aliases)
front matter field as server-relative URLs, resolved according to the current [content dimension](https://gohugo.io/quick-reference/glossary/#content-dimension)
.
The `Aliases` method is useful for generating a `_redirects` file, which contains a source URL, a target URL, and an HTTP status code for each alias. You can use a `_redirects` file with hosting services such as Cloudflare, GitLab Pages, and Netlify.
Redirects
---------
By default, Hugo handles aliases by creating individual HTML files for each alias path. These files contain a `meta http-equiv="refresh"` tag to redirect the visitor via the browser.
While functional, generating a single `_redirects` file allows your hosting provider to handle redirects at the server level. This is more efficient than client-side redirection and improves performance by eliminating the need to load a middle-man HTML page.
You can use the same general approach to generate an `.htaccess` file.
Example
-------
The following example demonstrates how to configure your site and create a template to automate the generation of a `_redirects` file.
### Content structure
The content structure for this multilingual example looks like this:
content/
├── examples/
│ ├── a.de.md aliases = ['a-old']
│ ├── a.en.md aliases = ['a-old', 'a-older']
│ ├── b.de.md aliases = ['b-old']
│ └── b.en.md aliases = ['b-old', 'b-older']
└── _index.md
In the example above, the aliases are [page-relative](https://gohugo.io/quick-reference/glossary/#page-relative)
. To specify a [site-relative](https://gohugo.io/quick-reference/glossary/#site-relative)
path, preface the entry with a slash (`/`). Both forms are resolved to [server-relative](https://gohugo.io/quick-reference/glossary/#server-relative)
paths.
Page-relative paths can also include directory traversal:
| Path type | File path | Alias | Server-relative path |
| --- | --- | --- | --- |
| page-relative | `content/examples/a.en.md` | `a-old` | `/en/examples/a-old/` |
| page-relative | `content/examples/a.en.md` | `../a-old` | `/en/a-old/` |
| site-relative | `content/examples/a.en.md` | `/a-old` | `/en/a-old/` |
### Project configuration
To implement this, you must update your project configuration to:
1. Disable the generation of default HTML redirect files by setting `disableAliases` to `true`.
2. Define a [media type](https://gohugo.io/configuration/media-types/)
named `text/redirects` to handle the file format.
3. Define a custom [output format](https://gohugo.io/configuration/output-formats/)
named `redirects` to set the filename to `_redirects` and place it at the root of the published site.
4. Configure the home page [outputs](https://gohugo.io/configuration/outputs/)
to include the `redirects` format in addition to `html`.
baseURL: https://example.org/
defaultContentLanguage: en
defaultContentLanguageInSubdir: true
disableAliases: true
languages:
de:
languageCode: de-DE
languageDirection: ltr
languageName: Deutsch
title: My Site in German
weight: 2
en:
languageCode: en-US
languageDirection: ltr
languageName: English
title: My Site in English
weight: 1
mediaTypes:
text/redirects:
delimiter: ''
outputFormats:
redirects:
baseName: _redirects
isPlainText: true
mediaType: text/redirects
root: true
outputs:
home:
- html
- redirects
baseURL = 'https://example.org/'
defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = true
disableAliases = true
[languages]
[languages.de]
languageCode = 'de-DE'
languageDirection = 'ltr'
languageName = 'Deutsch'
title = 'My Site in German'
weight = 2
[languages.en]
languageCode = 'en-US'
languageDirection = 'ltr'
languageName = 'English'
title = 'My Site in English'
weight = 1
[mediaTypes]
[mediaTypes.'text/redirects']
delimiter = ''
[outputFormats]
[outputFormats.redirects]
baseName = '_redirects'
isPlainText = true
mediaType = 'text/redirects'
root = true
[outputs]
home = ['html', 'redirects']
{
"baseURL": "https://example.org/",
"defaultContentLanguage": "en",
"defaultContentLanguageInSubdir": true,
"disableAliases": true,
"languages": {
"de": {
"languageCode": "de-DE",
"languageDirection": "ltr",
"languageName": "Deutsch",
"title": "My Site in German",
"weight": 2
},
"en": {
"languageCode": "en-US",
"languageDirection": "ltr",
"languageName": "English",
"title": "My Site in English",
"weight": 1
}
},
"mediaTypes": {
"text/redirects": {
"delimiter": ""
}
},
"outputFormats": {
"redirects": {
"baseName": "_redirects",
"isPlainText": true,
"mediaType": "text/redirects",
"root": true
}
},
"outputs": {
"home": [\
"html",\
"redirects"\
]
}
}
### Template implementation
Next, create a home page template specifically for the `redirects` output format. The following template iterates through every page in every language and extracts its aliases.
To ensure the resulting `_redirects` file is valid, the template uses the [`strings.FindRE`](https://gohugo.io/functions/strings/findre/)
function to check for whitespace such as tabs or newlines within the alias string. If whitespace is detected, Hugo will throw an error and fail the build to prevent generating an invalid file.
layouts/home.redirects
{{- if site.IsDefault -}}
{{- range hugo.Sites -}}
{{- range $p := .Pages -}}
{{- range .Aliases -}}
{{- if findRE `\s` . -}}
{{- errorf "One of the front matter aliases in %q contains whitespace" $p.String -}}
{{- end -}}
{{- printf "%s %s 301\n" . $p.RelPermalink -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
### Generated output
Once Hugo processes the template, it produces a clean list of redirect rules. Each line follows the required format: the source URL, the destination URL, and the HTTP status code.
The resulting `_redirects` file looks like this:
/de/examples/a-old /de/examples/a/ 301
/de/examples/b-old /de/examples/b/ 301
/en/examples/b-old /en/examples/b/ 301
/en/examples/b-older /en/examples/b/ 301
/en/examples/a-old /en/examples/a/ 301
/en/examples/a-older /en/examples/a/ 301
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/Aliases.md)
---
# Front matter
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Use front matter to add metadata to your content.
Overview
--------
The front matter at the top of each content file is metadata that:
* Describes the content
* Augments the content
* Establishes relationships with other content
* Controls the published structure of your site
* Determines template selection
Provide front matter using a serialization format, one of [JSON](https://www.json.org/)
, [TOML](https://toml.io/)
, or [YAML](https://yaml.org/)
. Hugo determines the front matter format by examining the delimiters that separate the front matter from the page content.
See examples of front matter delimiters by toggling between the serialization formats below.
---
date: 2024-02-02T04:14:54-08:00
draft: false
params:
author: John Smith
title: Example
weight: 10
---
+++
date = 2024-02-02T04:14:54-08:00
draft = false
title = 'Example'
weight = 10
[params]
author = 'John Smith'
+++
{
"date": "2024-02-02T04:14:54-08:00",
"draft": false,
"params": {
"author": "John Smith"
},
"title": "Example",
"weight": 10
}
Front matter fields may be [boolean](https://gohugo.io/quick-reference/glossary/#boolean)
, [integer](https://gohugo.io/quick-reference/glossary/#integer)
, [float](https://gohugo.io/quick-reference/glossary/#float)
, [string](https://gohugo.io/quick-reference/glossary/#string)
, [arrays](https://gohugo.io/quick-reference/glossary/#array)
, or [maps](https://gohugo.io/quick-reference/glossary/#map)
. Note that the TOML format also supports unquoted date/time values.
Fields
------
The most common front matter fields are `date`, `draft`, `title`, and `weight`, but you can specify metadata using any of fields below.
The field names below are reserved. For example, you cannot create a custom field named `type`. Create custom fields under the `params` key. See the [parameters](https://gohugo.io/content-management/front-matter/#parameters)
section for details.
aliases
(`[]string`) An array of one or more [page-relative](https://gohugo.io/quick-reference/glossary/#page-relative)
or [site-relative](https://gohugo.io/quick-reference/glossary/#site-relative)
paths that should redirect to the current page. Hugo resolves these to [server-relative](https://gohugo.io/quick-reference/glossary/#server-relative)
URLs during the build process. Access these values from a template using the [`Aliases`](https://gohugo.io/methods/page/aliases/)
method on a `Page` object. See the [aliases](https://gohugo.io/content-management/urls/#aliases)
section for details.
build
(`map`) A map of [build options](https://gohugo.io/content-management/build-options/)
.
cascade
(`map`) A map (or a slice of maps) of front matter keys whose values are passed down to the page’s descendants unless overwritten by self or a closer ancestor’s cascade. See the [cascade](https://gohugo.io/content-management/front-matter/#cascade-1)
section for details.
date
(`string`) The date associated with the page, typically the creation date. Note that the TOML format also supports unquoted date/time values. See the [dates](https://gohugo.io/content-management/front-matter/#dates)
section for examples. Access this value from a template using the [`Date`](https://gohugo.io/methods/page/date/)
method on a `Page` object.
description
(`string`) Conceptually different than the page `summary`, the description is typically rendered within a `meta` element within the `head` element of the published HTML file. Access this value from a template using the [`Description`](https://gohugo.io/methods/page/description/)
method on a `Page` object.
draft
(`bool`) Whether to disable rendering unless you pass the `--buildDrafts` flag to the `hugo` command. Access this value from a template using the [`Draft`](https://gohugo.io/methods/page/draft/)
method on a `Page` object.
expiryDate
(`string`) The page expiration date. On or after the expiration date, the page will not be rendered unless you pass the `--buildExpired` flag to the `hugo` command. Note that the TOML format also supports unquoted date/time values. See the [dates](https://gohugo.io/content-management/front-matter/#dates)
section for examples. Access this value from a template using the [`ExpiryDate`](https://gohugo.io/methods/page/expirydate/)
method on a `Page` object.
headless
(`bool`) Applicable to [leaf bundles](https://gohugo.io/content-management/page-bundles/#leaf-bundles)
, whether to set the `render` and `list` [build options](https://gohugo.io/content-management/build-options/)
to `never`, creating a headless bundle of [page resources](https://gohugo.io/content-management/page-resources/#metadata)
.
isCJKLanguage
(`bool`) Whether the content language is in the [CJK](https://gohugo.io/quick-reference/glossary/#cjk)
family. This value determines how Hugo calculates word count, and affects the values returned by the [`WordCount`](https://gohugo.io/methods/page/wordcount/)
, [`FuzzyWordCount`](https://gohugo.io/methods/page/wordcount/)
, [`ReadingTime`](https://gohugo.io/methods/page/readingtime/)
, and [`Summary`](https://gohugo.io/methods/page/summary/)
methods on a `Page` object.
keywords
(`[]string`) An array of keywords, typically rendered within a `meta` element within the `head` element of the published HTML file, or used as a [taxonomy](https://gohugo.io/quick-reference/glossary/#taxonomy)
to classify content. Access these values from a template using the [`Keywords`](https://gohugo.io/methods/page/keywords/)
method on a `Page` object.
lastmod
(`string`) The date that the page was last modified. Note that the TOML format also supports unquoted date/time values. See the [dates](https://gohugo.io/content-management/front-matter/#dates)
section for examples. Access this value from a template using the [`Lastmod`](https://gohugo.io/methods/page/date/)
method on a `Page` object.
layout
(`string`) Provide a template name to [target a specific template](https://gohugo.io/templates/lookup-order/#target-a-template)
, overriding the default [template lookup order](https://gohugo.io/templates/lookup-order/)
. Set the value to the base file name of the template, excluding its extension. Access this value from a template using the [`Layout`](https://gohugo.io/methods/page/layout/)
method on a `Page` object.
linkTitle
(`string`) Typically a shorter version of the `title`. Access this value from a template using the [`LinkTitle`](https://gohugo.io/methods/page/linktitle/)
method on a `Page` object.
markup
(`string`) An identifier corresponding to one of the supported [content formats](https://gohugo.io/content-management/formats/#classification)
. If not provided, Hugo determines the content renderer based on the file extension.
menus
(`string`, `[]string`, or `map`) If set, Hugo adds the page to the given menu or menus. See the [menus](https://gohugo.io/content-management/menus/#define-in-front-matter)
page for details.
modified
Alias to [lastmod](https://gohugo.io/content-management/front-matter/#lastmod)
.
outputs
(`[]string`) The [output formats](https://gohugo.io/configuration/output-formats/)
to render. See [configure outputs](https://gohugo.io/configuration/outputs/#outputs-per-page)
for more information.
params
(`map`) A map of custom [page parameters](https://gohugo.io/content-management/front-matter/#parameters)
.
pubdate
Alias to [publishDate](https://gohugo.io/content-management/front-matter/#publishdate)
.
publishDate
(`string`) The page publication date. Before the publication date, the page will not be rendered unless you pass the `--buildFuture` flag to the `hugo` command. Note that the TOML format also supports unquoted date/time values. See the [dates](https://gohugo.io/content-management/front-matter/#dates)
section for examples. Access this value from a template using the [`PublishDate`](https://gohugo.io/methods/page/publishdate/)
method on a `Page` object.
published
Alias to [publishDate](https://gohugo.io/content-management/front-matter/#publishdate)
.
resources
(`map array`) An array of maps to provide metadata for [page resources](https://gohugo.io/content-management/page-resources/#metadata)
.
sitemap
(`map`) A map of sitemap options. See the [sitemap templates](https://gohugo.io/templates/sitemap/)
page for details. Access these values from a template using the [`Sitemap`](https://gohugo.io/methods/page/sitemap/)
method on a `Page` object.
sites
[New in v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
(`map`) A map to define [sites matrix](https://gohugo.io/quick-reference/glossary/#sites-matrix)
and [sites complements](https://gohugo.io/quick-reference/glossary/#sites-complements)
for the page.
---
sites:
complements:
versions:
- v3.*.*
matrix:
languages:
- en
- fr
roles:
- '**'
versions:
- v1.2.*
- v2.*.*
title: Home
---
+++
title = 'Home'
[sites]
[sites.complements]
versions = ['v3.*.*']
[sites.matrix]
languages = ['en', 'fr']
roles = ['**']
versions = ['v1.2.*', 'v2.*.*']
+++
{
"sites": {
"complements": {
"versions": [\
"v3.*.*"\
]
},
"matrix": {
"languages": [\
"en",\
"fr"\
],
"roles": [\
"**"\
],
"versions": [\
"v1.2.*",\
"v2.*.*"\
]
}
},
"title": "Home"
}
slug
(`string`) Overrides the last segment of the URL path. Not applicable to `home`, `section`, `taxonomy`, or `term` pages. See the [URL management](https://gohugo.io/content-management/urls/#slug)
page for details. Access this value from a template using the [`Slug`](https://gohugo.io/methods/page/slug/)
method on a `Page` object.
summary
(`string`) Conceptually different than the page `description`, the summary either summarizes the content or serves as a teaser to encourage readers to visit the page. Access this value from a template using the [`Summary`](https://gohugo.io/methods/page/summary/)
method on a `Page` object.
title
(`string`) The page title. Access this value from a template using the [`Title`](https://gohugo.io/methods/page/title/)
method on a `Page` object.
translationKey
(`string`) An arbitrary value used to relate two or more translations of the same page, useful when the translated pages do not share a common path. Access this value from a template using the [`TranslationKey`](https://gohugo.io/methods/page/translationkey/)
method on a `Page` object.
type
(`string`) The [content type](https://gohugo.io/quick-reference/glossary/#content-type)
, overriding the value derived from the top-level section in which the page resides. Access this value from a template using the [`Type`](https://gohugo.io/methods/page/type/)
method on a `Page` object.
unpublishdate
Alias to [expirydate](https://gohugo.io/content-management/front-matter/#expirydate)
.
url
(`string`) Overrides the entire URL path. Applicable to regular pages and section pages. See the [URL management](https://gohugo.io/content-management/urls/#slug)
page for details.
weight
(`int`) The page [weight](https://gohugo.io/quick-reference/glossary/#weight)
, used to order the page within a [page collection](https://gohugo.io/quick-reference/glossary/#page-collection)
. Access this value from a template using the [`Weight`](https://gohugo.io/methods/page/weight/)
method on a `Page` object.
Parameters
----------
Specify custom page parameters under the `params` key in front matter:
---
date: 2024-02-02T04:14:54-08:00
draft: false
params:
author: John Smith
title: Example
weight: 10
---
+++
date = 2024-02-02T04:14:54-08:00
draft = false
title = 'Example'
weight = 10
[params]
author = 'John Smith'
+++
{
"date": "2024-02-02T04:14:54-08:00",
"draft": false,
"params": {
"author": "John Smith"
},
"title": "Example",
"weight": 10
}
Access these values from a template using the [`Params`](https://gohugo.io/methods/page/params/)
or [`Param`](https://gohugo.io/methods/page/param/)
method on a `Page` object.
Hugo provides [embedded templates](https://gohugo.io/templates/embedded/)
to optionally insert meta data within the `head` element of your rendered pages. These embedded templates expect the following front matter parameters:
| Parameter | Data type | Used by these embedded templates |
| --- | --- | --- |
| `audio` | `[]string` | [`opengraph.html`](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/opengraph.html) |
| `images` | `[]string` | [`opengraph.html`](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/opengraph.html) , [`schema.html`](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/schema.html) , [`twitter_cards.html`](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/twitter_cards.html) |
| `videos` | `[]string` | [`opengraph.html`](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/opengraph.html) |
The embedded templates will skip a parameter if not provided in front matter, but will throw an error if the data type is unexpected.
Taxonomies
----------
Classify content by adding taxonomy terms to front matter. For example, with this project configuration:
taxonomies:
genre: genres
tag: tags
[taxonomies]
genre = 'genres'
tag = 'tags'
{
"taxonomies": {
"genre": "genres",
"tag": "tags"
}
}
Add taxonomy terms as shown below:
---
date: 2024-02-02T04:14:54-08:00
draft: false
genres:
- mystery
- romance
params:
author: John Smith
tags:
- red
- blue
title: Example
weight: 10
---
+++
date = 2024-02-02T04:14:54-08:00
draft = false
genres = ['mystery', 'romance']
tags = ['red', 'blue']
title = 'Example'
weight = 10
[params]
author = 'John Smith'
+++
{
"date": "2024-02-02T04:14:54-08:00",
"draft": false,
"genres": [\
"mystery",\
"romance"\
],
"params": {
"author": "John Smith"
},
"tags": [\
"red",\
"blue"\
],
"title": "Example",
"weight": 10
}
You can add taxonomy terms to the front matter of any these [page kinds](https://gohugo.io/quick-reference/glossary/#page-kind)
:
* `home`
* `page`
* `section`
* `taxonomy`
* `term`
Access taxonomy terms from a template using the [`Params`](https://gohugo.io/methods/page/params/)
or [`GetTerms`](https://gohugo.io/methods/page/getterms/)
method on a `Page` object. For example:
layouts/page.html
{{ with .GetTerms "tags" }}
{{ end }}
Cascade
-------
A [node](https://gohugo.io/quick-reference/glossary/#node)
can cascade front matter values to its descendants. However, this cascading will be prevented if the descendant already defines the field, or if a closer ancestor node has already cascaded a value for that same field.
For example, to cascade a “color” parameter from the home page to all its descendants:
---
cascade:
params:
color: red
title: Home
---
+++
title = 'Home'
[cascade]
[cascade.params]
color = 'red'
+++
{
"cascade": {
"params": {
"color": "red"
}
},
"title": "Home"
}
[New in v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
From Hugo 0.153.0, you can also set the [sites](https://gohugo.io/content-management/front-matter/#sites)
front matter as cascade front matter values, which means that you can e.g. apply one or more languages to the `target` pages.
### Target
The `target`[1](https://gohugo.io/content-management/front-matter/#fn:1)
keyword allows you to target specific pages or [environments](https://gohugo.io/quick-reference/glossary/#environment)
. For example, to cascade a “color” parameter from the home page only to pages within the “articles” section, including the “articles” section page itself:
---
cascade:
params:
color: red
target:
path: '{/articles,/articles/**}'
sites:
matrix:
languages:
- en
- fr
title: Home
---
+++
title = 'Home'
[cascade]
[cascade.params]
color = 'red'
[cascade.target]
path = '{/articles,/articles/**}'
[cascade.target.sites]
[cascade.target.sites.matrix]
languages = ['en', 'fr']
+++
{
"cascade": {
"params": {
"color": "red"
},
"target": {
"path": "{/articles,/articles/**}",
"sites": {
"matrix": {
"languages": [\
"en",\
"fr"\
]
}
}
}
},
"title": "Home"
}
Use any combination of these keywords to target pages and/or environments:
environment
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching the build [environment](https://gohugo.io/quick-reference/glossary/#environment)
. For example: `{staging,production}`.
kind
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching the [page kind](https://gohugo.io/quick-reference/glossary/#page-kind)
. For example: `{taxonomy,term}`.
path
(`string`) A [glob pattern](https://gohugo.io/quick-reference/glossary/#glob-pattern)
matching the page’s [logical path](https://gohugo.io/quick-reference/glossary/#logical-path)
. For example: `{/books,/books/**}`.
sites
[New in v0.153.0](https://github.com/gohugoio/hugo/releases/tag/v0.153.0)
(`map`) A map to define [sites matrix](https://gohugo.io/quick-reference/glossary/#sites-matrix)
for the target, as in: Which sites should receive the cascaded values.
### Array
Define an array of cascade parameters to apply different values to different targets. For example:
---
cascade:
- params:
color: red
target:
kind: page
path: '{/books/**}'
- params:
color: blue
target:
kind: page
path: '{/films/**}'
title: Home
---
+++
title = 'Home'
[[cascade]]
[cascade.params]
color = 'red'
[cascade.target]
kind = 'page'
path = '{/books/**}'
[[cascade]]
[cascade.params]
color = 'blue'
[cascade.target]
kind = 'page'
path = '{/films/**}'
+++
{
"cascade": [\
{\
"params": {\
"color": "red"\
},\
"target": {\
"kind": "page",\
"path": "{/books/**}"\
}\
},\
{\
"params": {\
"color": "blue"\
},\
"target": {\
"kind": "page",\
"path": "{/films/**}"\
}\
}\
],
"title": "Home"
}
For multilingual projects, defining cascade values in your project configuration is often more efficient. This avoids repeating the same cascade values on the home, section, taxonomy, or term page for each language. See [details](https://gohugo.io/configuration/cascade/)
.
If you choose to define cascade values in front matter for a multilingual project, you must create a corresponding home, section, taxonomy, or term page for every language.
Emacs Org Mode
--------------
If your [content format](https://gohugo.io/content-management/formats/)
is [Emacs Org Mode](https://orgmode.org/)
, you may provide front matter using Org Mode keywords. For example:
content/example.org
#+TITLE: Example
#+DATE: 2024-02-02T04:14:54-08:00
#+DRAFT: false
#+AUTHOR: John Smith
#+GENRES: mystery
#+GENRES: romance
#+TAGS: red
#+TAGS: blue
#+WEIGHT: 10
Note that you can also specify array elements on a single line:
content/example.org
#+TAGS[]: red blue
Dates
-----
When populating a date field, whether a [custom page parameter](https://gohugo.io/content-management/front-matter/#parameters)
or one of the four predefined fields ([`date`](https://gohugo.io/content-management/front-matter/#date)
, [`expiryDate`](https://gohugo.io/content-management/front-matter/#expirydate)
, [`lastmod`](https://gohugo.io/content-management/front-matter/#lastmod)
, [`publishDate`](https://gohugo.io/content-management/front-matter/#publishdate)
), use one of these parsable formats:
| Format | Time zone |
| --- | --- |
| `2023-10-15T13:18:50-07:00` | `America/Los_Angeles` |
| `2023-10-15T13:18:50-0700` | `America/Los_Angeles` |
| `2023-10-15T13:18:50Z` | `Etc/UTC` |
| `2023-10-15T13:18:50` | Default is `Etc/UTC` |
| `2023-10-15` | Default is `Etc/UTC` |
| `15 Oct 2023` | Default is `Etc/UTC` |
The last three examples are not fully qualified, and default to the `Etc/UTC` time zone.
To override the default time zone, set the [`timeZone`](https://gohugo.io/configuration/all/#timezone)
in your project configuration. The order of precedence for determining the time zone is:
1. The time zone offset in the date/time string
2. The time zone specified in your project configuration
3. The `Etc/UTC` time zone
* * *
1. The `_target` alias for `target` is deprecated and will be removed in a future release. [↩︎](https://gohugo.io/content-management/front-matter/#fnref:1)
* * *
Last updated: February 26, 2026 : [content: More site-to-project changes (05b69f84e)](https://github.com/gohugoio/hugoDocs/commit/05b69f84e25e9cdd10ed1ac7ce5d37d4ac0b3725)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/content-management/front-matter.md)
---
# BundleType
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the bundle type of the given page, or an empty string if the page is not a page bundle.
Syntax
PAGE.BundleType
Returns
string
A page bundle is a directory that encapsulates both content and associated [resources](https://gohugo.io/quick-reference/glossary/#resource)
. There are two types of page bundles: [leaf bundles](https://gohugo.io/quick-reference/glossary/#leaf-bundle)
and [branch bundles](https://gohugo.io/quick-reference/glossary/#branch-bundle)
. See [details](https://gohugo.io/content-management/page-bundles/)
.
The `BundleType` method on a `Page` object returns `branch` for branch bundles, `leaf` for leaf bundles, and an empty string if the page is not a page bundle.
content/
├── films/
│ ├── film-1/
│ │ ├── a.jpg
│ │ └── index.md <-- leaf bundle
│ ├── _index.md <-- branch bundle
│ ├── b.jpg
│ ├── film-2.md
│ └── film-3.md
└── _index.md <-- branch bundle
To get the value within a template:
{{ .BundleType }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/BundleType.md)
---
# CodeOwners
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns of slice of code owners for the given page, derived from the CODEOWNERS file in the root of the project directory.
Syntax
PAGE.CodeOwners
Returns
\[\]string
GitHub and GitLab support CODEOWNERS files. This file specifies the users responsible for developing and maintaining software and documentation. This definition can apply to the entire repository, specific directories, or to individual files. To learn more:
* [GitHub CODEOWNERS documentation](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners)
* [GitLab CODEOWNERS documentation](https://docs.gitlab.com/ee/user/project/code_owners.html)
Use the `CodeOwners` method on a `Page` object to determine the code owners for the given page.
To use the `CodeOwners` method you must enable access to your local Git repository:
enableGitInfo: true
enableGitInfo = true
{
"enableGitInfo": true
}
Consider this project structure:
my-project/
├── content/
│ ├── books/
│ │ └── les-miserables.md
│ └── films/
│ └── the-hunchback-of-notre-dame.md
└── CODEOWNERS
And this CODEOWNERS file:
* @jdoe
/content/books/ @tjones
/content/films/ @mrichards @rsmith
The table below shows the slice of code owners returned for each file:
| Path | Code owners |
| --- | --- |
| `books/les-miserables.md` | `[@tjones]` |
| `films/the-hunchback-of-notre-dame.md` | `[@mrichards @rsmith]` |
Render the code owners for each content page:
{{ range .CodeOwners }}
{{ . }}
{{ end }}
Combine this method with [`resources.GetRemote`](https://gohugo.io/functions/resources/getremote/)
to retrieve names and avatars from your Git provider by querying their API.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/CodeOwners.md)
---
# Content
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the rendered content of the given page.
Syntax
PAGE.Content
Returns
template.HTML
The `Content` method on a `Page` object renders Markdown and shortcodes to HTML.
{{ .Content }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/Content.md)
---
# ContentWithoutSummary
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the rendered content of the given page, excluding the content summary.
Syntax
PAGE.ContentWithoutSummary
Returns
template.HTML
[New in v0.134.0](https://github.com/gohugoio/hugo/releases/tag/v0.134.0)
Applicable when using manual or automatic [content summaries](https://gohugo.io/content-management/summaries/#manual-summary)
, the `ContentWithoutSummary` method on a `Page` object renders Markdown and shortcodes to HTML, excluding the content summary from the result.
{{ .ContentWithoutSummary }}
The `ContentWithoutSummary` method returns the same as `Content` if you define the content summary in front matter.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/ContentWithoutSummary.md)
---
# CurrentSection
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the Page object of the section in which the given page resides.
Syntax
PAGE.CurrentSection
Returns
page.Page
A _section_ is a top-level content directory or any content directory containing an `_index.md` file.
The current section of a [section page](https://gohugo.io/quick-reference/glossary/#section-page)
, [taxonomy page](https://gohugo.io/quick-reference/glossary/#taxonomy-page)
, [term page](https://gohugo.io/quick-reference/glossary/#term-page)
, or the home page, is itself.
Consider this content structure:
content/
├── auctions/
│ ├── 2023-11/
│ │ ├── _index.md <-- current section: 2023-11
│ │ ├── auction-1.md
│ │ └── auction-2.md <-- current section: 2023-11
│ ├── 2023-12/
│ │ ├── _index.md
│ │ ├── auction-3.md
│ │ └── auction-4.md
│ ├── _index.md <-- current section: auctions
│ ├── bidding.md
│ └── payment.md <-- current section: auctions
├── books/
│ ├── _index.md <-- current section: books
│ ├── book-1.md
│ └── book-2.md <-- current section: books
├── films/
│ ├── _index.md <-- current section: films
│ ├── film-1.md
│ └── film-2.md <-- current section: films
└── _index.md <-- current section: home
To create a link to the current section page:
{{ .CurrentSection.LinkTitle }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/CurrentSection.md)
---
# Date
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the date of the given page.
Syntax
PAGE.Date
Returns
time.Time
Set the date in front matter:
---
date: 2023-10-19T00:40:04-07:00
title: Article 1
---
+++
date = 2023-10-19T00:40:04-07:00
title = 'Article 1'
+++
{
"date": "2023-10-19T00:40:04-07:00",
"title": "Article 1"
}
The date field in front matter is often considered to be the creation date, You can change its meaning, and its effect on your project, in your project configuration. See [details](https://gohugo.io/configuration/front-matter/#dates)
.
The date is a [time.Time](https://pkg.go.dev/time#Time)
value. Format and localize the value with the [`time.Format`](https://gohugo.io/functions/time/format/)
function, or use it with any of the [time methods](https://gohugo.io/methods/time/)
.
{{ .Date | time.Format ":date_medium" }} → Oct 19, 2023
In the example above we explicitly set the date in front matter. With Hugo’s default configuration, the `Date` method returns the front matter value. This behavior is configurable, allowing you to set fallback values if the date is not defined in front matter. See [details](https://gohugo.io/configuration/front-matter/#dates)
.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/Date.md)
---
# Data
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a unique data object for each page kind.
Syntax
PAGE.Data
Returns
page.Data
The `Data` method on a `Page` object returns a unique data object for each [page kind](https://gohugo.io/quick-reference/glossary/#page-kind)
.
The `Data` method is only useful within [taxonomy](https://gohugo.io/quick-reference/glossary/#taxonomy)
and [term](https://gohugo.io/quick-reference/glossary/#term)
templates.
Themes that are not actively maintained may still use `.Data.Pages` in their templates. Although that syntax remains functional, use one of these methods instead: [`Pages`](https://gohugo.io/methods/page/pages/)
, [`RegularPages`](https://gohugo.io/methods/page/regularpages/)
, or [`RegularPagesRecursive`](https://gohugo.io/methods/page/regularpagesrecursive/)
The examples that follow are based on this project configuration:
taxonomies:
author: authors
genre: genres
[taxonomies]
author = 'authors'
genre = 'genres'
{
"taxonomies": {
"author": "authors",
"genre": "genres"
}
}
And this content structure:
content/
├── books/
│ ├── and-then-there-were-none.md --> genres: suspense
│ ├── death-on-the-nile.md --> genres: suspense
│ └── jamaica-inn.md --> genres: suspense, romance
│ └── pride-and-prejudice.md --> genres: romance
└── _index.md
In a taxonomy template
----------------------
Use these methods on the `Data` object within a _taxonomy_ template.
Singular
(`string`) Returns the singular name of the taxonomy.
{{ .Data.Singular }} → genre
Plural
(`string`) Returns the plural name of the taxonomy.
{{ .Data.Plural }} → genres
Terms
(`page.Taxonomy`) Returns the `Taxonomy` object, consisting of a map of terms and the [weighted pages](https://gohugo.io/quick-reference/glossary/#weighted-page)
associated with each term.
{{ $taxonomyObject := .Data.Terms }}
Once you have captured the `Taxonomy` object, use any of the [taxonomy methods](https://gohugo.io/methods/taxonomy/)
to sort, count, or capture a subset of its weighted pages.
Learn more about [taxonomy templates](https://gohugo.io/templates/types/#taxonomy)
.
In a term template
------------------
Use these methods on the `Data` object within a _term_ template.
Singular
(`string`) Returns the singular name of the taxonomy.
{{ .Data.Singular }} → genre
Plural
(`string`) Returns the plural name of the taxonomy.
{{ .Data.Plural }} → genres
Term
(`string`) Returns the name of the term.
{{ .Data.Term }} → suspense
Learn more about [term templates](https://gohugo.io/templates/types/#term)
.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/Data.md)
---
# Description
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the description of the given page as defined in front matter.
Syntax
PAGE.Description
Returns
string
Conceptually different from a [content summary](https://gohugo.io/content-management/summaries/)
, a page description is typically used in metadata about the page.
---
description: Instructions for making spicy tuna hand rolls.
title: How to make spicy tuna hand rolls
---
+++
description = 'Instructions for making spicy tuna hand rolls.'
title = 'How to make spicy tuna hand rolls'
+++
{
"description": "Instructions for making spicy tuna hand rolls.",
"title": "How to make spicy tuna hand rolls"
}
layouts/baseof.html
...
...
* * *
Last updated: July 7, 2025 : [Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45' (079671b41)](https://github.com/gohugoio/hugoDocs/commit/079671b41b9395f2c2b48879f14d3f09d69a63dc)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/Description.md)
---
# Draft
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports whether the given page is a draft as defined in front matter.
Syntax
PAGE.Draft
Returns
bool
By default, Hugo does not publish draft pages when you build your project. To include draft pages when you build your project, use the `--buildDrafts` command line flag.
---
draft: true
title: Post 1
---
+++
draft = true
title = 'Post 1'
+++
{
"draft": true,
"title": "Post 1"
}
{{ .Draft }} → true
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/Draft.md)
---
# Eq
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports whether two Page objects are equal.
Syntax
PAGE1.Eq PAGE2
Returns
bool
In this contrived example we list all pages in the current section except for the current page.
layouts/page.html
{{ $currentPage := . }}
{{ range .CurrentSection.Pages }}
{{ if not (.Eq $currentPage) }}
{{ .LinkTitle }}
{{ end }}
{{ end }}
* * *
Last updated: July 7, 2025 : [Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45' (079671b41)](https://github.com/gohugoio/hugoDocs/commit/079671b41b9395f2c2b48879f14d3f09d69a63dc)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/Eq.md)
---
# ExpiryDate
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the expiry date of the given page.
Syntax
PAGE.ExpiryDate
Returns
time.Time
By default, Hugo excludes expired pages when building your project. To include expired pages, use the `--buildExpired` command line flag.
Set the expiry date in front matter:
---
expiryDate: 2024-10-19T00:32:13-07:00
title: Article 1
---
+++
expiryDate = 2024-10-19T00:32:13-07:00
title = 'Article 1'
+++
{
"expiryDate": "2024-10-19T00:32:13-07:00",
"title": "Article 1"
}
The expiry date is a [time.Time](https://pkg.go.dev/time#Time)
value. Format and localize the value with the [`time.Format`](https://gohugo.io/functions/time/format/)
function, or use it with any of the [time methods](https://gohugo.io/methods/time/)
.
{{ .ExpiryDate | time.Format ":date_medium" }} → Oct 19, 2024
In the example above we explicitly set the expiry date in front matter. With Hugo’s default configuration, the `ExpiryDate` method returns the front matter value. This behavior is configurable, allowing you to set fallback values if the expiry date is not defined in front matter. See [details](https://gohugo.io/configuration/front-matter/#dates)
.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/ExpiryDate.md)
---
# FirstSection
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the Page object of the top-level section of which the given page is a descendant.
Syntax
PAGE.FirstSection
Returns
page.Page
A _section_ is a top-level content directory or any content directory containing an `_index.md` file.
When called on the home page, the `FirstSection` method returns the `Page` object of the home page itself.
Consider this content structure:
content/
├── auctions/
│ ├── 2023-11/
│ │ ├── _index.md <-- first section: auctions
│ │ ├── auction-1.md
│ │ └── auction-2.md <-- first section: auctions
│ ├── 2023-12/
│ │ ├── _index.md
│ │ ├── auction-3.md
│ │ └── auction-4.md
│ ├── _index.md <-- first section: auctions
│ ├── bidding.md
│ └── payment.md <-- first section: auctions
├── books/
│ ├── _index.md <-- first section: books
│ ├── book-1.md
│ └── book-2.md <-- first section: books
├── films/
│ ├── _index.md <-- first section: films
│ ├── film-1.md
│ └── film-2.md <-- first section: films
└── _index.md <-- first section: home
To link to the top-level section of which the current page is a descendant:
{{ .FirstSection.LinkTitle }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/FirstSection.md)
---
# File
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

For pages backed by a file, returns file information for the given page.
Syntax
PAGE.File
Returns
hugolib.fileInfo
By default, not all pages are backed by a file, including top-level [section pages](https://gohugo.io/quick-reference/glossary/#section-page)
, [taxonomy pages](https://gohugo.io/quick-reference/glossary/#taxonomy-page)
, and [term pages](https://gohugo.io/quick-reference/glossary/#term-page)
. By definition, you cannot retrieve file information when the file does not exist.
To back one of the pages above with a file, create an `_index.md` file in the corresponding directory. For example:
content/
└── books/
├── _index.md <-- the top-slevel section page
├── book-1.md
└── book-2.md
Code defensively by verifying file existence as shown in the examples below.
Methods
-------
The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend on the operating system.
### BaseFileName
(`string`) The file name, excluding the extension.
{{ with .File }}
{{ .BaseFileName }}
{{ end }}
### ContentBaseName
(`string`) If the page is a branch or leaf bundle, the name of the containing directory, else the `TranslationBaseName`.
{{ with .File }}
{{ .ContentBaseName }}
{{ end }}
### Dir
(`string`) The file path, excluding the file name, relative to the `content` directory.
{{ with .File }}
{{ .Dir }}
{{ end }}
### Ext
(`string`) The file extension.
{{ with .File }}
{{ .Ext }}
{{ end }}
### Filename
(`string`) The absolute file path.
{{ with .File }}
{{ .Filename }}
{{ end }}
### IsContentAdapter
(`bool`) Reports whether the file is a [content adapter](https://gohugo.io/content-management/content-adapters/)
.
{{ with .File }}
{{ .IsContentAdapter }}
{{ end }}
### LogicalName
(`string`) The file name.
{{ with .File }}
{{ .LogicalName }}
{{ end }}
### Path
(`string`) The file path, relative to the `content` directory.
{{ with .File }}
{{ .Path }}
{{ end }}
### Section
(`string`) The name of the top-level section in which the file resides.
{{ with .File }}
{{ .Section }}
{{ end }}
### TranslationBaseName
(`string`) The file name, excluding the extension and language identifier.
{{ with .File }}
{{ .TranslationBaseName }}
{{ end }}
### UniqueID
(`string`) The MD5 hash of `.File.Path`.
{{ with .File }}
{{ .UniqueID }}
{{ end }}
Examples
--------
Consider this content structure in a multilingual project:
content/
├── news/
│ ├── b/
│ │ ├── index.de.md <-- leaf bundle
│ │ └── index.en.md <-- leaf bundle
│ ├── a.de.md <-- regular content
│ ├── a.en.md <-- regular content
│ ├── _index.de.md <-- branch bundle
│ └── _index.en.md <-- branch bundle
├── _index.de.md
└── _index.en.md
With the English language site:
| | regular content | leaf bundle | branch bundle |
| --- | --- | --- | --- |
| BaseFileName | a.en | index.en | \_index.en |
| ContentBaseName | a | b | news |
| Dir | news/ | news/b/ | news/ |
| Ext | md | md | md |
| Filename | /home/user/… | /home/user/… | /home/user/… |
| IsContentAdapter | false | false | false |
| LogicalName | a.en.md | index.en.md | \_index.en.md |
| Path | news/a.en.md | news/b/index.en.md | news/\_index.en.md |
| Section | news | news | news |
| TranslationBaseName | a | index | \_index |
| UniqueID | 15be14b… | 186868f… | 7d9159d… |
Defensive coding
----------------
Some of the pages on a site may not be backed by a file. For example:
* Top-level section pages
* Taxonomy pages
* Term pages
Without a backing file, Hugo will throw an error if you attempt to access a `.File` property. To code defensively, first check for file existence:
{{ with .File }}
{{ .ContentBaseName }}
{{ end }}
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/File.md)
---
# FuzzyWordCount
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns the number of words in the content of the given page, rounded up to the nearest multiple of 100.
Syntax
PAGE.FuzzyWordCount
Returns
int
{{ .FuzzyWordCount }} → 200
To get the exact word count, use the [`WordCount`](https://gohugo.io/methods/page/wordcount/)
method.
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/FuzzyWordCount.md)
---
# Fragments
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a data structure of the fragments in the given page.
Syntax
PAGE.Fragments
Returns
tableofcontents.Fragments
In a URL, whether absolute or relative, the [fragment](https://gohugo.io/quick-reference/glossary/#fragment)
links to an `id` attribute of an HTML element on the page.
/articles/article-1#section-2
------------------- ---------
path fragment
Hugo assigns an `id` attribute to each Markdown [ATX](https://spec.commonmark.org/current/#atx-headings)
and [setext](https://spec.commonmark.org/current/#setext-headings)
heading within the page content. You can override the `id` with a [Markdown attribute](https://gohugo.io/quick-reference/glossary/#markdown-attribute)
as needed. This creates the relationship between an entry in the [table of contents](https://gohugo.io/methods/page/tableofcontents/)
(TOC) and a heading on the page.
Use the `Fragments` method on a `Page` object to create a table of contents with the `Fragments.ToHTML` method, or by [walking](https://gohugo.io/quick-reference/glossary/#walk)
the `Fragments.Map` data structure.
Methods
-------
### Headings
(`slice`) A slice of maps of all headings on the page, with first-level keys for each heading. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
{{ debug.Dump .Fragments.Headings }}
### HeadingsMap
(`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
{{ debug.Dump .Fragments.HeadingsMap }}
### Identifiers
(`slice`) A slice containing the `id` attribute of each heading on the page. If so configured, will also contain the `id` attribute of each description term (i.e., `dt` element) on the page.
See [configure Markup](https://gohugo.io/configuration/markup/#parserautodefinitiontermid)
.
To inspect the data structure:
{{ debug.Dump .Fragments.Identifiers }}
### Identifiers.Contains ID
(`bool`) Reports whether one or more headings on the page has the given `id` attribute, useful for validating fragments within a link [render hook](https://gohugo.io/quick-reference/glossary/#render-hook)
.
{{ .Fragments.Identifiers.Contains "section-2" }} → true
### Identifiers.Count ID
(`int`) The number of headings on a page with the given `id` attribute, useful for detecting duplicates.
{{ .Fragments.Identifiers.Count "section-2" }} → 1
### ToHTML
(`template.HTML`) Returns a TOC as a nested list, either ordered or unordered, identical to the HTML returned by the [`TableOfContents`](https://gohugo.io/methods/page/tableofcontents/)
method. This method take three arguments: the start level (`int`), the end level (`int`), and a boolean (`true` to return an ordered list, `false` to return an unordered list).
Use this method when you want to control the start level, end level, or list type independently from the table of contents settings in your project configuration.
{{ $startLevel := 2 }}
{{ $endLevel := 3 }}
{{ $ordered := true }}
{{ .Fragments.ToHTML $startLevel $endLevel $ordered }}
Hugo renders this to:
It is safe to use the `Fragments` methods within a render hook, even for the current page.
When using the `Fragments` methods within a shortcode, call the shortcode using [standard notation](https://gohugo.io/content-management/shortcodes/#notation)
. If you use [Markdown notation](https://gohugo.io/content-management/shortcodes/#notation)
the rendered shortcode is included in the creation of the fragments map, resulting in a circular loop.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/Fragments.md)
---
# GetTerms
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a collection of term pages for terms defined on the given page in the given taxonomy, ordered according to the sequence in which they appear in front matter.
Syntax
PAGE.GetTerms TAXONOMY
Returns
page.Pages
Given this front matter:
---
tags:
- historical
- classic
- fiction
title: Les Misérables
---
+++
tags = ['historical', 'classic', 'fiction']
title = 'Les Misérables'
+++
{
"tags": [\
"historical",\
"classic",\
"fiction"\
],
"title": "Les Misérables"
}
This template code:
{{ with .GetTerms "tags" }}
* * *
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/GetTerms.md)
---
# GetPage
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Returns a Page object from the given path.
Syntax
PAGE.GetPage PATH
Returns
page.Page
The `GetPage` method is also available on a `Site` object. See [details](https://gohugo.io/methods/site/getpage/)
.
When using the `GetPage` method on the `Page` object, specify a path relative to the current directory or relative to the `content` directory.
If Hugo cannot resolve the path to a page, the method returns nil. If the path is ambiguous, Hugo throws an error and fails the build.
Consider this content structure:
content/
├── works/
│ ├── paintings/
│ │ ├── _index.md
│ │ ├── starry-night.md
│ │ └── the-mona-lisa.md
│ ├── sculptures/
│ │ ├── _index.md
│ │ ├── david.md
│ │ └── the-thinker.md
│ └── _index.md
└── _index.md
The examples below depict the result of rendering `works/paintings/the-mona-lisa.md`:
layouts/works/page.html
{{ with .GetPage "starry-night" }}
{{ .Title }} → Starry Night
{{ end }}
{{ with .GetPage "./starry-night" }}
{{ .Title }} → Starry Night
{{ end }}
{{ with .GetPage "../paintings/starry-night" }}
{{ .Title }} → Starry Night
{{ end }}
{{ with .GetPage "/works/paintings/starry-night" }}
{{ .Title }} → Starry Night
{{ end }}
{{ with .GetPage "../sculptures/david" }}
{{ .Title }} → David
{{ end }}
{{ with .GetPage "/works/sculptures/david" }}
{{ .Title }} → David
{{ end }}
* * *
Last updated: July 7, 2025 : [Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45' (079671b41)](https://github.com/gohugoio/hugoDocs/commit/079671b41b9395f2c2b48879f14d3f09d69a63dc)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/GetPage.md)
---
# GitInfo
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Provides access to commit metadata for a given page.
Syntax
PAGE.GitInfo
Returns
\*gitmap.GitInfo
The `GitInfo` method on a `Page` object provides access to commit metadata from your Git history, such as the author’s name, the commit hash, and the commit message.
Hugo’s Git integration is performant, but may increase build times for large projects.
Prerequisites
-------------
Install Git, create a repository, and commit your project files.
You must also allow Hugo to access your repository by adding this to your project configuration:
enableGitInfo: true
enableGitInfo = true
{
"enableGitInfo": true
}
When you set [`enableGitInfo`](https://gohugo.io/configuration/all/#enablegitinfo)
to `true`, the last modification date for each content page will automatically be the Author Date of the last commit for that file.
This is configurable. See [details](https://gohugo.io/configuration/front-matter/#dates)
.
Scope
-----
Commit metadata is available for content stored in your local repository and for content provided by [modules](https://gohugo.io/quick-reference/glossary/#module)
.
### Local content
Hugo retrieves commit metadata for files tracked within your project’s local repository. This includes all content files managed by Git in your main project directory.
### Module content
[New in v0.157.0](https://github.com/gohugoio/hugo/releases/tag/v0.157.0)
Hugo also retrieves commit metadata for content provided by modules. This allows you to display commit data for remote repositories that are mounted as content directories, such as when aggregating documentation from multiple sources.
Methods
-------
### AbbreviatedHash
(`string`) Returns the seven-character shortened version of the commit hash.
{{ with .GitInfo }}
{{ .AbbreviatedHash }} → aab9ec0
{{ end }}
### AuthorDate
(`time.Time`) Returns the date the author originally created the commit.
{{ with .GitInfo }}
{{ .AuthorDate.Format "2006-01-02" }} → 2023-10-09
{{ end }}
### AuthorEmail
(`string`) Returns the author’s email address, respecting [gitmailmap](https://git-scm.com/docs/gitmailmap)
.
{{ with .GitInfo }}
{{ .AuthorEmail }} → jsmith@example.org
{{ end }}
### AuthorName
(`string`) Returns the author’s name, respecting [gitmailmap](https://git-scm.com/docs/gitmailmap)
.
{{ with .GitInfo }}
{{ .AuthorName }} → John Smith
{{ end }}
### CommitDate
(`time.Time`) Returns the date the commit was applied to the branch.
{{ with .GitInfo }}
{{ .CommitDate.Format "2006-01-02" }} → 2023-10-09
{{ end }}
### Hash
(`string`) Returns the full SHA-1 commit hash.
{{ with .GitInfo }}
{{ .Hash }} → aab9ec0b31ebac916a1468c4c9c305f2bebf78d4
{{ end }}
### Subject
(`string`) Returns the first line of the commit message (the summary).
{{ with .GitInfo }}
{{ .Subject }} → Add tutorials
{{ end }}
### Body
(`string`) Returns the full content of the commit message, excluding the subject line.
{{ with .GitInfo }}
{{ .Body }} → Two new pages added.
{{ end }}
### Ancestors
(`gitmap.GitInfos`) Returns a list of previous commits for this specific file, ordered from most recent to oldest.
For example, to list the last 5 commits:
{{ with .GitInfo }}
{{ range .Ancestors | first 5 }}
{{ .CommitDate.Format "2006-01-02" }}: {{ .Subject }}
{{ end }}
{{ end }}
To reverse the order:
{{ with .GitInfo }}
{{ range .Ancestors.Reverse | first 5 }}
{{ .CommitDate.Format "2006-01-02" }}: {{ .Subject }}
{{ end }}
{{ end }}
### Parent
(`*gitmap.GitInfo`) Returns the most recent ancestor commit for the file, if any.
Last modified date
------------------
By default, when `enableGitInfo` is `true`, the `Lastmod` method on a `Page` object returns the Git AuthorDate of the last commit that included the file.
You can change this behavior in your [project configuration](https://gohugo.io/configuration/front-matter/)
.
Hosting considerations
----------------------
On a [CI/CD](https://gohugo.io/quick-reference/glossary/#cicd)
platform, the step that clones your project repository must perform a deep clone. If the clone is shallow, the Git information for a given file may be inaccurate. It might incorrectly reflect the most recent repository commit, rather than the commit that actually modified the file.
While some providers perform a deep clone by default, others require you to configure the depth yourself.
| Hosting service | Default clone depth | Configurable |
| --- | --- | --- |
| AWS Amplify | Deep | N/A |
| Cloudflare | Shallow | Yes [1](https://gohugo.io/methods/page/gitinfo/#fn:1) |
| DigitalOcean App Platform | Deep | N/A |
| GitHub Pages | Shallow | Yes [2](https://gohugo.io/methods/page/gitinfo/#fn:2) |
| GitLab Pages | Shallow | Yes [3](https://gohugo.io/methods/page/gitinfo/#fn:3) |
| Netlify | Deep | N/A |
| Render | Shallow | Yes [1](https://gohugo.io/methods/page/gitinfo/#fn:1) |
| Vercel | Shallow | Yes [1](https://gohugo.io/methods/page/gitinfo/#fn:1) |
* * *
1. To perform a deep clone when hosting on Cloudflare, Render, or Vercel, include this code in the build script after the repository has been cloned:
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
git fetch --unshallow
fi
[↩︎](https://gohugo.io/methods/page/gitinfo/#fnref:1)
[↩︎](https://gohugo.io/methods/page/gitinfo/#fnref1:1)
[↩︎](https://gohugo.io/methods/page/gitinfo/#fnref2:1)
2. To perform a deep clone when hosting on GitHub Pages, set `fetch-depth: 0` in the `checkout` step of the GitHub Action. See [example](https://gohugo.io/host-and-deploy/host-on-github-pages/#step-7)
. [↩︎](https://gohugo.io/methods/page/gitinfo/#fnref:2)
3. To perform a deep clone when hosting on GitLab Pages, set the `GIT_DEPTH` environment variable to `0` in the workflow file. See [example](https://gohugo.io/host-and-deploy/host-on-gitlab-pages/#configure-gitlab-cicd)
. [↩︎](https://gohugo.io/methods/page/gitinfo/#fnref:3)
* * *
Last updated: February 27, 2026 : [content: Miscellaneous udpates for v0.157.0 (35da1aa3c)](https://github.com/gohugoio/hugoDocs/commit/35da1aa3c2fe3b54bdb57df1a308533844af9df5)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/GitInfo.md)
---
# HasMenuCurrent
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

Reports whether the given Page object matches the Page object associated with one of the child menu entries under the given menu entry in the given menu.
Syntax
PAGE.HasMenuCurrent MENU MENUENTRY
Returns
bool
If the `Page` object associated with the menu entry is a section, this method also returns `true` for any descendant of that section.
{{ $currentPage := . }}
{{ range site.Menus.main }}
{{ if $currentPage.IsMenuCurrent .Menu . }}
{{ .Name }}
{{ else if $currentPage.HasMenuCurrent .Menu . }}
{{ .Name }}
{{ else }}
{{ .Name }}
{{ end }}
{{ end }}
See [menu templates](https://gohugo.io/templates/menu/#example)
for a complete example.
When using this method you must either define the menu entry in front matter, or specify a `pageRef` property when defining the menu entry in your project configuration.
* * *
Last updated: February 25, 2026 : [Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)](https://github.com/gohugoio/hugoDocs/commit/b0d3364f14192a13e95a5d30e9e3af1febb0bf57)
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/methods/page/HasMenuCurrent.md)
---
# Functions
Menu
Search
[GitHub 87080 stars](https://github.com/gohugoio/hugo)
[Mastodon](https://fosstodon.org/@gohugoio)
Hugo Documentation

A quick reference guide to Hugo’s functions, grouped by namespace. Aliases, if any, appear in parentheses to the right of the function name.
cast
----
Use these functions to cast a value from one data type to another.
[cast.ToFloat](https://gohugo.io/functions/cast/tofloat/)
Converts a value to a decimal floating-point number (base 10).
[cast.ToInt](https://gohugo.io/functions/cast/toint/)
Converts a value to a decimal integer (base 10).
[cast.ToString](https://gohugo.io/functions/cast/tostring/)
Converts a value to a string.
collections
-----------
Use these functions to manipulate and query maps, slices, and strings.
[collections.After](https://gohugo.io/functions/collections/after/)
Returns a slice containing the elements after the first N elements of the given slice.
[collections.Append](https://gohugo.io/functions/collections/append/)
Returns a slice by adding one or more elements, or an entire second slice, to the end of the given slice.
[collections.Apply](https://gohugo.io/functions/collections/apply/)
Returns a slice by transforming each element of the given slice using a specific function and parameters.
[collections.Complement](https://gohugo.io/functions/collections/complement/)
Returns a slice by identifying elements in the last given slice that do not appear in any of the preceding slices.
[collections.D](https://gohugo.io/functions/collections/d/)
Returns a sorted slice of unique random integers based on a given seed, count, and maximum value.
[collections.Delimit](https://gohugo.io/functions/collections/delimit/)
Returns a string by joining the values of the given slice or map with a delimiter.
[collections.Dictionary](https://gohugo.io/functions/collections/dictionary/)
Returns a map created from the given key-value pairs.
[collections.First](https://gohugo.io/functions/collections/first/)
Returns the first N elements of the given slice or string.
[collections.Group](https://gohugo.io/functions/collections/group/)
Returns a map by grouping the given page collection (slice) by a specific key.
[collections.In](https://gohugo.io/functions/collections/in/)
Reports whether a value exists within the given slice or string.
[collections.Index](https://gohugo.io/functions/collections/indexfunction/)
Returns an element or value from the given slice or map at the specified key(s).
[collections.Intersect](https://gohugo.io/functions/collections/intersect/)
Returns a slice containing the common elements found in two given slices, in the same order as the first slice.
[collections.IsSet](https://gohugo.io/functions/collections/isset/)
Reports whether a specific key or index exists in the given map or slice.
[collections.KeyVals](https://gohugo.io/functions/collections/keyvals/)
Returns a KeyVals struct by pairing a given key and values.
[collections.Last](https://gohugo.io/functions/collections/last/)
Returns the last N elements of the given slice or string.
[collections.Merge](https://gohugo.io/functions/collections/merge/)
Returns a map by combining two or more given maps.
[collections.NewScratch](https://gohugo.io/functions/collections/newscratch/)
Returns a locally scoped "scratch pad" to store and manipulate data.
[collections.Querify](https://gohugo.io/functions/collections/querify/)
Returns a URL query string from the given map, slice, or sequence of key-value pairs.
[collections.Reverse](https://gohugo.io/functions/collections/reverse/)
Returns a slice by reversing the order of elements in the given slice.
[collections.Seq](https://gohugo.io/functions/collections/seq/)
Returns a slice of integers starting from 1 or a given value, incrementing by 1 or a given value, and ending at a given value.
[collections.Shuffle](https://gohugo.io/functions/collections/shuffle/)
Returns a slice by randomizing the element order of the given slice.
[collections.Slice](https://gohugo.io/functions/collections/slice/)
Returns a slice created from the given values.
[collections.Sort](https://gohugo.io/functions/collections/sort/)
Returns a sorted map or slice by reordering the given collection by a key and order.
[collections.SymDiff](https://gohugo.io/functions/collections/symdiff/)
Returns a slice containing the symmetric difference of two given slices.
[collections.Union](https://gohugo.io/functions/collections/union/)
Returns a slice containing the unique elements from two given slices.
[collections.Uniq](https://gohugo.io/functions/collections/uniq/)
Returns a slice by removing duplicate elements from the given slice.
[collections.Where](https://gohugo.io/functions/collections/where/)
Returns a slice by filtering the given slice based on a key, operator, and value.
compare
-------
Use these functions to compare two or more values.
[compare.Conditional](https://gohugo.io/functions/compare/conditional/)
Returns one of two arguments depending on the value of the control argument.
[compare.Default](https://gohugo.io/functions/compare/default/)
Returns the second argument if set, else the first argument.
[compare.Eq](https://gohugo.io/functions/compare/eq/)
Returns the boolean truth of arg1 == arg2 || arg1 == arg3.
[compare.Ge](https://gohugo.io/functions/compare/ge/)
Returns the boolean truth of arg1 >= arg2 && arg1 >= arg3.
[compare.Gt](https://gohugo.io/functions/compare/gt/)
Returns the boolean truth of arg1 > arg2 && arg1 > arg3.
[compare.Le](https://gohugo.io/functions/compare/le/)
Returns the boolean truth of arg1 <= arg2 && arg1 <= arg3.
[compare.Lt](https://gohugo.io/functions/compare/lt/)
Returns the boolean truth of arg1 < arg2 && arg1 < arg3.
[compare.Ne](https://gohugo.io/functions/compare/ne/)
Returns the boolean truth of arg1 != arg2 && arg1 != arg3.
crypto
------
Use these functions to create cryptographic hashes.
[crypto.FNV32a](https://gohugo.io/functions/crypto/fnv32a/)
Returns the 32-bit FNV (Fowler-Noll-Vo) non-cryptographic hash of the given string.
[crypto.HMAC](https://gohugo.io/functions/crypto/hmac/)
Returns a cryptographic hash that uses a key to sign a message.
[crypto.MD5](https://gohugo.io/functions/crypto/md5/)
Hashes the given input and returns its MD5 checksum encoded to a hexadecimal string.
[crypto.SHA1](https://gohugo.io/functions/crypto/sha1/)
Hashes the given input and returns its SHA1 checksum encoded to a hexadecimal string.
[crypto.SHA256](https://gohugo.io/functions/crypto/sha256/)
Hashes the given input and returns its SHA256 checksum encoded to a hexadecimal string.
css
---
Use these functions to work with CSS and Sass files.
[css.PostCSS](https://gohugo.io/functions/css/postcss/)
Processes the given resource with PostCSS using any PostCSS plugin.
[css.Quoted](https://gohugo.io/functions/css/quoted/)
Returns the given string, setting its data type to indicate that it must be quoted when used in CSS.
[css.Sass](https://gohugo.io/functions/css/sass/)
Transpiles Sass to CSS.
[css.TailwindCSS](https://gohugo.io/functions/css/tailwindcss/)
Processes the given resource with the Tailwind CSS CLI.
[css.Unquoted](https://gohugo.io/functions/css/unquoted/)
Returns the given string, setting its data type to indicate that it must not be quoted when used in CSS.
debug
-----
Use these functions to debug your templates.
[debug.Dump](https://gohugo.io/functions/debug/dump/)
Returns an object dump as a string.
[debug.Timer](https://gohugo.io/functions/debug/timer/)
Creates a named timer that reports elapsed time to the console.
[debug.VisualizeSpaces](https://gohugo.io/functions/debug/visualizespaces/)
Returns the given string with spaces replaced by a visible string.
diagrams
--------
Use these functions to render diagrams.
[diagrams.Goat](https://gohugo.io/functions/diagrams/goat/)
Returns an SVGDiagram object created from the given GoAT markup and options.
encoding
--------
Use these functions to encode and decode data.
[encoding.Base64Decode](https://gohugo.io/functions/encoding/base64decode/)
Returns the base64 decoding of the given content.
[encoding.Base64Encode](https://gohugo.io/functions/encoding/base64encode/)
Returns the base64 decoding of the given content.
[encoding.Jsonify](https://gohugo.io/functions/encoding/jsonify/)
Encodes the given object to JSON.
fmt
---
Use these functions to print strings within a template or to print messages to the terminal.
[fmt.Errorf](https://gohugo.io/functions/fmt/errorf/)
Log an ERROR from a template.
[fmt.Erroridf](https://gohugo.io/functions/fmt/erroridf/)
Log a suppressible ERROR from a template.
[fmt.Print](https://gohugo.io/functions/fmt/print/)
Prints the default representation of the given arguments using the standard `fmt.Print` function.
[fmt.Printf](https://gohugo.io/functions/fmt/printf/)
Formats a string using the standard `fmt.Sprintf` function.
[fmt.Println](https://gohugo.io/functions/fmt/println/)
Prints the default representation of the given argument using the standard `fmt.Print` function and enforces a line break.
[fmt.Warnf](https://gohugo.io/functions/fmt/warnf/)
Log a WARNING from a template.
[fmt.Warnidf](https://gohugo.io/functions/fmt/warnidf/)
Log a suppressible WARNING from a template.
global
------
Use these global functions to access page and site data.
[page](https://gohugo.io/functions/global/page/)
Provides global access to a Page object.
[site](https://gohugo.io/functions/global/site/)
Provides global access to the current Site object.
go template
-----------
These are the functions, operators, and statements provided by Go's text/template package.
[and](https://gohugo.io/functions/go-template/and/)
Returns the first falsy argument. If all arguments are truthy, returns the last argument.
[block](https://gohugo.io/functions/go-template/block/)
Defines a template and executes it in place.
[break](https://gohugo.io/functions/go-template/break/)
Used with the range statement, stops the innermost iteration and bypasses all remaining iterations.
[continue](https://gohugo.io/functions/go-template/continue/)
Used with the range statement, stops the innermost iteration and continues to the next iteration.
[define](https://gohugo.io/functions/go-template/define/)
Defines a template.
[else](https://gohugo.io/functions/go-template/else/)
Begins an alternate block for if, with, and range statements.
[end](https://gohugo.io/functions/go-template/end/)
Terminates if, with, range, block, and define statements.
[if](https://gohugo.io/functions/go-template/if/)
Executes the block if the expression is truthy.
[len](https://gohugo.io/functions/go-template/len/)
Returns the length of a string, slice, map, or collection.
[not](https://gohugo.io/functions/go-template/not/)
Returns the boolean negation of its single argument.
[or](https://gohugo.io/functions/go-template/or/)
Returns the first truthy argument. If all arguments are falsy, returns the last argument.
[range](https://gohugo.io/functions/go-template/range/)
Iterates over a non-empty collection, binds context (the dot) to successive elements, and executes the block.
[return](https://gohugo.io/functions/go-template/return/)
Used within partial templates, terminates template execution and returns the given value, if any.
[template](https://gohugo.io/functions/go-template/template/)
Executes the given template, optionally passing context.
[try](https://gohugo.io/functions/go-template/try/)
Returns a TryValue object after evaluating the given expression.
[urlquery](https://gohugo.io/functions/go-template/urlquery/)
Returns the escaped value of the textual representation of its arguments in a form suitable for embedding in a URL query.
[with](https://gohugo.io/functions/go-template/with/)
Binds context (the dot) to the expression and executes the block if expression is truthy.
hash
----
Use these functions to create non-cryptographic hashes.
[hash.FNV32a](https://gohugo.io/functions/hash/fnv32a/)
Returns the 32-bit FNV (Fowler-Noll-Vo) non-cryptographic hash of the given string.
[hash.XxHash](https://gohugo.io/functions/hash/xxhash/)
Returns the 64-bit xxHash non-cryptographic hash of the given string.
hugo
----
Use these functions to access information about the Hugo application and the current environment.
[hugo.BuildDate](https://gohugo.io/functions/hugo/builddate/)
Returns the compile date of the Hugo binary.
[hugo.CommitHash](https://gohugo.io/functions/hugo/commithash/)
Returns the Git commit hash of the Hugo binary.
[hugo.Data](https://gohugo.io/functions/hugo/data/)
Returns a data structure composed from the files in the data directory.
[hugo.Deps](https://gohugo.io/functions/hugo/deps/)
Returns a slice of project dependencies, either Hugo Modules or local theme components.
[hugo.Environment](https://gohugo.io/functions/hugo/environment/)
Returns the current running environment.
[hugo.Generator](https://gohugo.io/functions/hugo/generator/)
Renders an HTML meta element identifying the software that generated the site.
[hugo.GoVersion](https://gohugo.io/functions/hugo/goversion/)
Returns the Go version used to compile the Hugo binary
[hugo.IsDevelopment](https://gohugo.io/functions/hugo/isdevelopment/)
Reports whether the current running environment is "development".
[hugo.IsExtended](https://gohugo.io/functions/hugo/isextended/)
Reports whether the Hugo binary is either the extended or extended/deploy edition.
[hugo.IsMultihost](https://gohugo.io/functions/hugo/ismultihost/)
Reports whether each configured language has a unique base URL.
[hugo.IsMultilingual](https://gohugo.io/functions/hugo/ismultilingual/)
Reports whether there are two or more configured languages.
[hugo.IsProduction](https://gohugo.io/functions/hugo/isproduction/)
Reports whether the current running environment is "production".
[hugo.IsServer](https://gohugo.io/functions/hugo/isserver/)
Reports whether the built-in development server is running.
[hugo.Sites](https://gohugo.io/functions/hugo/sites/)
Returns a collection of all sites for all dimensions.
[hugo.Store](https://gohugo.io/functions/hugo/store/)
Returns a globally scoped "scratch pad" to store and manipulate data.
[hugo.Version](https://gohugo.io/functions/hugo/version/)
Returns the current version of the Hugo binary.
[hugo.WorkingDir](https://gohugo.io/functions/hugo/workingdir/)
Returns the project working directory.
images
------
Use these functions to create an image filter, apply an image filter to an image, and to retrieve image information.
[images.AutoOrient](https://gohugo.io/functions/images/autoorient/)
Returns an image filter that rotates and flips an image as needed per its Exif orientation tag.
[images.Brightness](https://gohugo.io/functions/images/brightness/)
Returns an image filter that changes the brightness of an image.
[images.ColorBalance](https://gohugo.io/functions/images/colorbalance/)
Returns an image filter that changes the color balance of an image.
[images.Colorize](https://gohugo.io/functions/images/colorize/)
Returns an image filter that produces a colorized version of an image.
[images.Config](https://gohugo.io/functions/images/config/)
Returns an image.Config structure from the image at the specified path, relative to the working directory.
[images.Contrast](https://gohugo.io/functions/images/contrast/)
Returns an image filter that changes the contrast of an image.
[images.Dither](https://gohugo.io/functions/images/dither/)
Returns an image filter that dithers an image.
[images.Filter](https://gohugo.io/functions/images/filter/)
Applies one or more image filters to the given image resource.
[images.Gamma](https://gohugo.io/functions/images/gamma/)
Returns an image filter that performs gamma correction on an image.
[images.GaussianBlur](https://gohugo.io/functions/images/gaussianblur/)
Returns an image filter that applies a gaussian blur to an image.
[images.Grayscale](https://gohugo.io/functions/images/grayscale/)
Returns an image filter that produces a grayscale version of an image.
[images.Hue](https://gohugo.io/functions/images/hue/)
Returns an image filter that rotates the hue of an image.
[images.Invert](https://gohugo.io/functions/images/invert/)
Returns an image filter that negates the colors of an image.
[images.Mask](https://gohugo.io/functions/images/mask/)
Returns an image filter that applies a mask to the source image.
[images.Opacity](https://gohugo.io/functions/images/opacity/)
Returns an image filter that changes the opacity of an image.
[images.Overlay](https://gohugo.io/functions/images/overlay/)
Returns an image filter that overlays the source image at the given coordinates, relative to the upper left corner.
[images.Padding](https://gohugo.io/functions/images/padding/)
Returns an image filter that resizes the image canvas without resizing the image.
[images.Pixelate](https://gohugo.io/functions/images/pixelate/)
Returns an image filter that applies a pixelation effect to an image.
[images.Process](https://gohugo.io/functions/images/process/)
Returns an image filter that processes an image according to the given processing specification.
[images.QR](https://gohugo.io/functions/images/qr/)
Encodes the given text into a QR code using the specified options, returning an image resource.
[images.Saturation](https://gohugo.io/functions/images/saturation/)
Returns an image filter that changes the saturation of an image.
[images.Sepia](https://gohugo.io/functions/images/sepia/)
Returns an image filter that produces a sepia-toned version of an image.
[images.Sigmoid](https://gohugo.io/functions/images/sigmoid/)
Returns an image filter that changes the contrast of an image using a sigmoidal function.
[images.Text](https://gohugo.io/functions/images/text/)
Returns an image filter that adds text to an image.
[images.UnsharpMask](https://gohugo.io/functions/images/unsharpmask/)
Returns an image filter that sharpens an image.
inflect
-------
These functions provide word inflection features such as singularization and pluralization of English nouns.
[inflect.Humanize](https://gohugo.io/functions/inflect/humanize/)
Returns the humanized version of the input with the first letter capitalized.
[inflect.Pluralize](https://gohugo.io/functions/inflect/pluralize/)
Pluralizes the given word according to a set of common English pluralization rules.
[inflect.Singularize](https://gohugo.io/functions/inflect/singularize/)
Singularizes the given word according to a set of common English singularization rules.
js
--
Use these functions to work with JavaScript and TypeScript files.
[js.Babel](https://gohugo.io/functions/js/babel/)
Compile the given JavaScript resource with Babel.
[js.Batch](https://gohugo.io/functions/js/batch/)
Build JavaScript bundle groups with global code splitting and flexible hooks/runners setup.
[js.Build](https://gohugo.io/functions/js/build/)
Bundle, transpile, tree shake, and minify JavaScript resources.
lang
----
Use these functions to adapt your site to meet language and regional requirements.
[lang.FormatAccounting](https://gohugo.io/functions/lang/formataccounting/)
Returns a currency representation of a number for the given currency and precision for the current language and region in accounting notation.
[lang.FormatCurrency](https://gohugo.io/functions/lang/formatcurrency/)
Returns a currency representation of a number for the given currency and precision for the current language and region.
[lang.FormatNumber](https://gohugo.io/functions/lang/formatnumber/)
Returns a numeric representation of a number with the given precision for the current language and region.
[lang.FormatNumberCustom](https://gohugo.io/functions/lang/formatnumbercustom/)
Returns a numeric representation of a number with the given precision using negative, decimal, and grouping options.
[lang.FormatPercent](https://gohugo.io/functions/lang/formatpercent/)
Returns a percentage representation of a number with the given precision for the current language and region.
[lang.Merge](https://gohugo.io/functions/lang/merge/)
Merge missing translations from other languages.
[lang.Translate](https://gohugo.io/functions/lang/translate/)
Translates a string using the translation tables in the i18n directory.
math
----
Use these functions to perform mathematical operations.
[math.Abs](https://gohugo.io/functions/math/abs/)
Returns the absolute value of the given number.
[math.Acos](https://gohugo.io/functions/math/acos/)
Returns the arccosine, in radians, of the given number.
[math.Add](https://gohugo.io/functions/math/add/)
Adds two or more numbers.
[math.Asin](https://gohugo.io/functions/math/asin/)
Returns the arcsine, in radians, of the given number.
[math.Atan](https://gohugo.io/functions/math/atan/)
Returns the arctangent, in radians, of the given number.
[math.Atan2](https://gohugo.io/functions/math/atan2/)
Returns the arctangent, in radians, of the given number pair, determining the correct quadrant from their signs.
[math.Ceil](https://gohugo.io/functions/math/ceil/)
Returns the least integer value greater than or equal to the given number.
[math.Cos](https://gohugo.io/functions/math/cos/)
Returns the cosine of the given radian number.
[math.Counter](https://gohugo.io/functions/math/counter/)
Increments and returns a global counter.
[math.Div](https://gohugo.io/functions/math/div/)
Divides the first number by one or more numbers.
[math.Floor](https://gohugo.io/functions/math/floor/)
Returns the greatest integer value less than or equal to the given number.
[math.Log](https://gohugo.io/functions/math/log/)
Returns the natural logarithm of the given number.
[math.Max](https://gohugo.io/functions/math/max/)
Returns the greater of all numbers. Accepts scalars, slices, or both.
[math.MaxInt64](https://gohugo.io/functions/math/maxint64/)
Returns the maximum value for a signed 64-bit integer.
[math.Min](https://gohugo.io/functions/math/min/)
Returns the smaller of all numbers. Accepts scalars, slices, or both.
[math.Mod](https://gohugo.io/functions/math/mod/)
Returns the modulus of two integers.
[math.ModBool](https://gohugo.io/functions/math/modbool/)
Reports whether the modulus of two integers equals 0.
[math.Mul](https://gohugo.io/functions/math/mul/)
Multiplies two or more numbers.
[math.Pi](https://gohugo.io/functions/math/pi/)
Returns the mathematical constant pi.
[math.Pow](https://gohugo.io/functions/math/pow/)
Returns the first number raised to the power of the second number.
[math.Product](https://gohugo.io/functions/math/product/)
Returns the product of all numbers. Accepts scalars, slices, or both.
[math.Rand](https://gohugo.io/functions/math/rand/)
Returns a pseudo-random number in the half-open interval \[0.0, 1.0).\
\
[math.Round](https://gohugo.io/functions/math/round/)\
\
Returns the nearest integer, rounding half away from zero.\
\
[math.Sin](https://gohugo.io/functions/math/sin/)\
\
Returns the sine of the given radian number.\
\
[math.Sqrt](https://gohugo.io/functions/math/sqrt/)\
\
Returns the square root of the given number.\
\
[math.Sub](https://gohugo.io/functions/math/sub/)\
\
Subtracts one or more numbers from the first number.\
\
[math.Sum](https://gohugo.io/functions/math/sum/)\
\
Returns the sum of all numbers. Accepts scalars, slices, or both.\
\
[math.Tan](https://gohugo.io/functions/math/tan/)\
\
Returns the tangent of the given radian number.\
\
[math.ToDegrees](https://gohugo.io/functions/math/todegrees/)\
\
ToDegrees converts radians into degrees.\
\
[math.ToRadians](https://gohugo.io/functions/math/toradians/)\
\
ToRadians converts degrees into radians.\
\
openapi3\
--------\
\
Use these functions to work with OpenAPI 3 definitions.\
\
[openapi3.Unmarshal](https://gohugo.io/functions/openapi3/unmarshal/)\
\
Unmarshals the given resource into an OpenAPI 3 Description.\
\
os\
--\
\
Use these functions to interact with the operating system.\
\
[os.FileExists](https://gohugo.io/functions/os/fileexists/)\
\
Reports whether the file or directory exists.\
\
[os.Getenv](https://gohugo.io/functions/os/getenv/)\
\
Returns the value of an environment variable, or an empty string if the environment variable is not set.\
\
[os.ReadDir](https://gohugo.io/functions/os/readdir/)\
\
Returns an array of FileInfo structures sorted by file name, one element for each directory entry.\
\
[os.ReadFile](https://gohugo.io/functions/os/readfile/)\
\
Returns the contents of a file.\
\
[os.Stat](https://gohugo.io/functions/os/stat/)\
\
Returns a FileInfo structure describing a file or directory.\
\
partials\
--------\
\
Use these functions to call partial templates.\
\
[partials.Include](https://gohugo.io/functions/partials/include/)\
\
Executes the given template, optionally passing context. If the partial template contains a return statement, returns the given value, else returns the rendered output.\
\
[partials.IncludeCached](https://gohugo.io/functions/partials/includecached/)\
\
Executes the given template and caches the result, optionally passing one or more variant keys. If the partial template contains a return statement, returns the given value, else returns the rendered output.\
\
path\
----\
\
Use these functions to work with file paths.\
\
[path.Base](https://gohugo.io/functions/path/base/)\
\
Replaces path separators with slashes (`/`) and returns the last element of the given path.\
\
[path.BaseName](https://gohugo.io/functions/path/basename/)\
\
Replaces path separators with slashes (`/`) and returns the last element of the given path, removing the extension if present.\
\
[path.Clean](https://gohugo.io/functions/path/clean/)\
\
Replaces path separators with slashes (`/`) and returns the shortest path name equivalent to the given path.\
\
[path.Dir](https://gohugo.io/functions/path/dir/)\
\
Replaces path separators with slashes (/) and returns all but the last element of the given path.\
\
[path.Ext](https://gohugo.io/functions/path/ext/)\
\
Replaces path separators with slashes (`/`) and returns the file name extension of the given path.\
\
[path.Join](https://gohugo.io/functions/path/join/)\
\
Replaces path separators with slashes (`/`), joins the given path elements into a single path, and returns the shortest path name equivalent to the result.\
\
[path.Split](https://gohugo.io/functions/path/split/)\
\
Replaces path separators with slashes (`/`) and splits the resulting path immediately following the final slash, separating it into a directory and file name component.\
\
reflect\
-------\
\
Use these functions to determine a value's data type.\
\
[reflect.IsImageResource](https://gohugo.io/functions/reflect/isimageresource/)\
\
Reports whether the given value is a Resource object representing an image as defined by its media type.\
\
[reflect.IsImageResourceProcessable](https://gohugo.io/functions/reflect/isimageresourceprocessable/)\
\
Reports whether the given value is a Resource object representing an image from which Hugo can extract dimensions and perform processing such as converting, resizing, cropping, or filtering.\
\
[reflect.IsImageResourceWithMeta](https://gohugo.io/functions/reflect/isimageresourcewithmeta/)\
\
Reports whether the given value is a Resource object representing an image from which Hugo can extract dimensions and, if present, Exif, IPTC, and XMP data.\
\
[reflect.IsMap](https://gohugo.io/functions/reflect/ismap/)\
\
Reports whether the given value is a map.\
\
[reflect.IsPage](https://gohugo.io/functions/reflect/ispage/)\
\
Reports whether the given value is a Page object.\
\
[reflect.IsResource](https://gohugo.io/functions/reflect/isresource/)\
\
Reports whether the given value is a Resource object.\
\
[reflect.IsSite](https://gohugo.io/functions/reflect/issite/)\
\
Reports whether the given value is a Site object.\
\
[reflect.IsSlice](https://gohugo.io/functions/reflect/isslice/)\
\
Reports whether the given value is a slice.\
\
resources\
---------\
\
Use these functions to work with resources.\
\
[resources.Babel](https://gohugo.io/functions/resources/babel/)\
\
Compiles the given JavaScript resource with Babel.\
\
[resources.ByType](https://gohugo.io/functions/resources/bytype/)\
\
Returns a collection of global resources of the given media type, or nil if none found.\
\
[resources.Concat](https://gohugo.io/functions/resources/concat/)\
\
Returns a concatenated slice of resources.\
\
[resources.Copy](https://gohugo.io/functions/resources/copy/)\
\
Copies the given resource to the target path.\
\
[resources.ExecuteAsTemplate](https://gohugo.io/functions/resources/executeastemplate/)\
\
Returns a resource created from a Go template, parsed and executed with the given context.\
\
[resources.Fingerprint](https://gohugo.io/functions/resources/fingerprint/)\
\
Cryptographically hashes the content of the given resource.\
\
[resources.FromString](https://gohugo.io/functions/resources/fromstring/)\
\
Returns a resource created from a string.\
\
[resources.Get](https://gohugo.io/functions/resources/get/)\
\
Returns a global resource from the given path, or nil if none found.\
\
[resources.GetMatch](https://gohugo.io/functions/resources/getmatch/)\
\
Returns the first global resource from paths matching the given glob pattern, or nil if none found.\
\
[resources.GetRemote](https://gohugo.io/functions/resources/getremote/)\
\
Returns a remote resource from the given URL, or nil if none found.\
\
[resources.Match](https://gohugo.io/functions/resources/match/)\
\
Returns a collection of global resources from paths matching the given glob pattern, or nil if none found.\
\
[resources.Minify](https://gohugo.io/functions/resources/minify/)\
\
Minifies the given resource.\
\
[resources.PostCSS](https://gohugo.io/functions/resources/postcss/)\
\
Processes the given resource with PostCSS using any PostCSS plugin.\
\
[resources.PostProcess](https://gohugo.io/functions/resources/postprocess/)\
\
Processes the given resource after the build.\
\
[resources.ToCSS](https://gohugo.io/functions/resources/tocss/)\
\
Transpiles Sass to CSS.\
\
safe\
----\
\
Use these functions to declare a value as safe in the context of Go's html/template package.\
\
[safe.CSS](https://gohugo.io/functions/safe/css/)\
\
Declares the given string as a safe CSS string.\
\
[safe.HTML](https://gohugo.io/functions/safe/html/)\
\
Declares the given string as a safeHTML string.\
\
[safe.HTMLAttr](https://gohugo.io/functions/safe/htmlattr/)\
\
Declares the given key-value pair as a safe HTML attribute.\
\
[safe.JS](https://gohugo.io/functions/safe/js/)\
\
Declares the given string as a safe JavaScript expression.\
\
[safe.JSStr](https://gohugo.io/functions/safe/jsstr/)\
\
Declares the given string as a safe JavaScript string.\
\
[safe.URL](https://gohugo.io/functions/safe/url/)\
\
Declares the given string as a safe URL or URL substring.\
\
strings\
-------\
\
Use these functions to work with strings.\
\
[strings.Chomp](https://gohugo.io/functions/strings/chomp/)\
\
Returns the given string, removing all trailing newline characters and carriage returns.\
\
[strings.Contains](https://gohugo.io/functions/strings/contains/)\
\
Reports whether the given string contains the given substring.\
\
[strings.ContainsAny](https://gohugo.io/functions/strings/containsany/)\
\
Reports whether the given string contains any character within the given set.\
\
[strings.ContainsNonSpace](https://gohugo.io/functions/strings/containsnonspace/)\
\
Reports whether the given string contains any non-space characters as defined by Unicode.\
\
[strings.Count](https://gohugo.io/functions/strings/count/)\
\
Returns the number of non-overlapping instances of the given substring within the given string.\
\
[strings.CountRunes](https://gohugo.io/functions/strings/countrunes/)\
\
Returns the number of runes in the given string excluding whitespace.\
\
[strings.CountWords](https://gohugo.io/functions/strings/countwords/)\
\
Returns the number of words in the given string.\
\
[strings.Diff](https://gohugo.io/functions/strings/diff/)\
\
Returns an anchored diff of the two texts OLD and NEW in the unified diff format. If OLD and NEW are identical, returns an empty string.\
\
[strings.FindRE](https://gohugo.io/functions/strings/findre/)\
\
Returns a slice of strings that match the regular expression.\
\
[strings.FindRESubmatch](https://gohugo.io/functions/strings/findresubmatch/)\
\
Returns a slice of all successive matches of the regular expression. Each element is a slice of strings holding the text of the leftmost match of the regular expression and the matches, if any, of its subexpressions.\
\
[strings.FirstUpper](https://gohugo.io/functions/strings/firstupper/)\
\
Returns the given string, capitalizing the first character.\
\
[strings.HasPrefix](https://gohugo.io/functions/strings/hasprefix/)\
\
Reports whether the given string begins with the given prefix.\
\
[strings.HasSuffix](https://gohugo.io/functions/strings/hassuffix/)\
\
Reports whether the given string ends with the given suffix.\
\
[strings.Repeat](https://gohugo.io/functions/strings/repeat/)\
\
Returns a new string consisting of zero or more copies of another string.\
\
[strings.Replace](https://gohugo.io/functions/strings/replace/)\
\
Returns a copy of INPUT, replacing all occurrences of OLD with NEW.\
\
[strings.ReplaceRE](https://gohugo.io/functions/strings/replacere/)\
\
Returns a copy of INPUT, replacing all occurrences of a regular expression with a replacement pattern.\
\
[strings.RuneCount](https://gohugo.io/functions/strings/runecount/)\
\
Returns the number of runes in the given string.\
\
[strings.SliceString](https://gohugo.io/functions/strings/slicestring/)\
\
Returns a substring of the given string, beginning with the start position and ending before the end position.\
\
[strings.Split](https://gohugo.io/functions/strings/split/)\
\
Returns a slice of strings by splitting the given string by a delimiter.\
\
[strings.Substr](https://gohugo.io/functions/strings/substr/)\
\
Returns a substring of the given string, beginning with the start position and ending after the given length.\
\
[strings.Title](https://gohugo.io/functions/strings/title/)\
\
Returns the given string, converting it to title case.\
\
[strings.ToLower](https://gohugo.io/functions/strings/tolower/)\
\
Returns the given string, converting all characters to lowercase.\
\
[strings.ToUpper](https://gohugo.io/functions/strings/toupper/)\
\
Returns the given string, converting all characters to uppercase.\
\
[strings.Trim](https://gohugo.io/functions/strings/trim/)\
\
Returns the given string, removing leading and trailing characters specified in the cutset.\
\
[strings.TrimLeft](https://gohugo.io/functions/strings/trimleft/)\
\
Returns the given string, removing leading characters specified in the cutset.\
\
[strings.TrimPrefix](https://gohugo.io/functions/strings/trimprefix/)\
\
Returns the given string, removing the prefix from the beginning of the string.\
\
[strings.TrimRight](https://gohugo.io/functions/strings/trimright/)\
\
Returns the given string, removing trailing characters specified in the cutset.\
\
[strings.TrimSpace](https://gohugo.io/functions/strings/trimspace/)\
\
Returns the given string, removing leading and trailing whitespace as defined by Unicode.\
\
[strings.TrimSuffix](https://gohugo.io/functions/strings/trimsuffix/)\
\
Returns the given string, removing the suffix from the end of the string.\
\
[strings.Truncate](https://gohugo.io/functions/strings/truncate/)\
\
Returns the given string, truncating it to a maximum length without cutting words or leaving unclosed HTML tags.\
\
templates\
---------\
\
Use these functions to query the template system.\
\
[templates.Current](https://gohugo.io/functions/templates/current/)\
\
Returns information about the currently executing template.\
\
[templates.Defer](https://gohugo.io/functions/templates/defer/)\
\
Defer execution of a template until after all sites and output formats have been rendered.\
\
[templates.Exists](https://gohugo.io/functions/templates/exists/)\
\
Reports whether a template file exists under the given path relative to the layouts directory.\
\
[templates.Inner](https://gohugo.io/functions/templates/inner/)\
\
Executes the content block enclosed by a partial call.\
\
time\
----\
\
Use these functions to work with time values.\
\
[time.AsTime](https://gohugo.io/functions/time/astime/)\
\
Returns the given string representation of a date/time value as a time.Time value.\
\
[time.Duration](https://gohugo.io/functions/time/duration/)\
\
Returns a time.Duration value using the given time unit and number.\
\
[time.Format](https://gohugo.io/functions/time/format/)\
\
Returns the given date/time as a formatted and localized string.\
\
[time.In](https://gohugo.io/functions/time/in/)\
\
Returns the given date/time as represented in the specified IANA time zone.\
\
[time.Now](https://gohugo.io/functions/time/now/)\
\
Returns the current local time.\
\
[time.ParseDuration](https://gohugo.io/functions/time/parseduration/)\
\
Returns a time.Duration value by parsing the given duration string.\
\
transform\
---------\
\
Use these functions to transform values from one format to another.\
\
[transform.CanHighlight](https://gohugo.io/functions/transform/canhighlight/)\
\
Reports whether the given code language is supported by the Chroma highlighter.\
\
[transform.Emojify](https://gohugo.io/functions/transform/emojify/)\
\
Runs a string through the Emoji emoticons processor.\
\
[transform.Highlight](https://gohugo.io/functions/transform/highlight/)\
\
Renders code with a syntax highlighter.\
\
[transform.HighlightCodeBlock](https://gohugo.io/functions/transform/highlightcodeblock/)\
\
Highlights code received in context within a code block render hook.\
\
[transform.HTMLEscape](https://gohugo.io/functions/transform/htmlescape/)\
\
Returns the given string, escaping special characters by replacing them with HTML entities.\
\
[transform.HTMLToMarkdown](https://gohugo.io/functions/transform/htmltomarkdown/)\
\
Converts HTML to Markdown.\
\
[transform.HTMLUnescape](https://gohugo.io/functions/transform/htmlunescape/)\
\
Returns the given string, replacing each HTML entity with its corresponding character.\
\
[transform.Markdownify](https://gohugo.io/functions/transform/markdownify/)\
\
Renders Markdown to HTML.\
\
[transform.Plainify](https://gohugo.io/functions/transform/plainify/)\
\
Returns a string with all HTML tags removed.\
\
[transform.PortableText](https://gohugo.io/functions/transform/portabletext/)\
\
Converts Portable Text to Markdown.\
\
[transform.Remarshal](https://gohugo.io/functions/transform/remarshal/)\
\
Marshals a string of serialized data, or a map, into a string of serialized data in the specified format.\
\
[transform.ToMath](https://gohugo.io/functions/transform/tomath/)\
\
Renders mathematical equations and expressions written in the LaTeX markup language.\
\
[transform.Unmarshal](https://gohugo.io/functions/transform/unmarshal/)\
\
Parses serialized data and returns a map or an array. Supports CSV, JSON, TOML, YAML, and XML.\
\
[transform.XMLEscape](https://gohugo.io/functions/transform/xmlescape/)\
\
Returns the given string, removing disallowed characters then escaping the result to its XML equivalent.\
\
urls\
----\
\
Use these functions to work with URLs.\
\
[urls.AbsLangURL](https://gohugo.io/functions/urls/abslangurl/)\
\
Returns an absolute URL with a language prefix, if any.\
\
[urls.AbsURL](https://gohugo.io/functions/urls/absurl/)\
\
Returns an absolute URL.\
\
[urls.Anchorize](https://gohugo.io/functions/urls/anchorize/)\
\
Returns the given string, sanitized for usage in an HTML id attribute.\
\
[urls.JoinPath](https://gohugo.io/functions/urls/joinpath/)\
\
Joins the provided elements into a URL string and cleans the result of any ./ or ../ elements. If the argument list is empty, JoinPath returns an empty string.\
\
[urls.Parse](https://gohugo.io/functions/urls/parse/)\
\
Parses a URL into a URL structure.\
\
[urls.PathEscape](https://gohugo.io/functions/urls/pathescape/)\
\
Returns the given string, applying percent-encoding to special characters and reserved delimiters so it can be safely used as a segment within a URL path.\
\
[urls.PathUnescape](https://gohugo.io/functions/urls/pathunescape/)\
\
Returns the given string, replacing all percent-encoded sequences with the corresponding unescaped characters.\
\
[urls.Ref](https://gohugo.io/functions/urls/ref/)\
\
Returns the absolute URL of the page with the given path, language, and output format.\
\
[urls.RelLangURL](https://gohugo.io/functions/urls/rellangurl/)\
\
Returns a relative URL with a language prefix, if any.\
\
[urls.RelRef](https://gohugo.io/functions/urls/relref/)\
\
Returns the relative URL of the page with the given path, language, and output format.\
\
[urls.RelURL](https://gohugo.io/functions/urls/relurl/)\
\
Returns a relative URL.\
\
[urls.URLize](https://gohugo.io/functions/urls/urlize/)\
\
Returns the given string, sanitized for usage in a URL.\
\
* * *\
\
Last updated: April 10, 2025 : [Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)](https://github.com/gohugoio/hugoDocs/commit/283e9778348774c2282f193fc7cf459e45a5c107)\
\
[Improve this page](https://github.com/gohugoio/hugoDocs/edit/master/content/en/quick-reference/functions.md)
---