HUGO

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
Star

What's on this Page

  • GitHub workflow
  • Including sample code
  • Admonitions
CONTRIBUTE

Contribute to the Hugo Docs

Documentation is an integral part of any open source project. The Hugo documentation is as much a work in progress as the source it attempts to cover.

GitHub workflow

Step 1
Fork the documentation repository.
Step 2
Clone your fork.
Step 3
Create a new branch with a descriptive name.
git checkout -b fix/typos-site-variables
Step 4
Make changes.
Step 5
Commit your changes with a descriptive commit message, typically 50 characters or less. Included the “Closes” keyword if your change addresses one or more open issues.
git commit -m "Fix typos on site variables page

Closes #1234
Closes #5678"
Step 5
Push the new branch to your fork of the documentation repository.
Step 6
Visit the documentation repository and create a pull request (PR).
Step 7
A project maintainer will review your PR, and may request changes. You may delete your branch after the maintainer merges your PR.

Including sample code

Use this syntax to include shortcodes calls within your code samples:

{{</* foo */>}}
{{%/* foo */%}}

Fenced code blocks

Include the language when using a fenced code block.

```go-html-template
{{ if eq $foo "bar" }}
  {{ print "foo is bar" }}
{{ end }}
```

Rendered:

{{ if eq $foo "bar" }}
  {{ print "foo is bar" }}
{{ end }}

The code shortcode

Use the code shortcode to include the file name and a copy-to-clipboard button. This shortcode accepts these optional parameters:

copy
(bool) If true, displays a copy-to-clipboard button. Default is true.
file
(string) The file name to display. If you do not provide a lang parameter, the file extension determines the code language.
lang
(string) The code language. Default is text.
{{< code file="layouts/_default_/single.html" >}}
{{ if eq $foo "bar" }}
  {{ print "foo is bar" }}
{{ end }}
{{< /code >}}

Rendered:

layouts/_default_/single.html
{{ if eq $foo "bar" }}
  {{ print "foo is bar" }}
{{ end }}

The code-toggle shortcode

Use the code-toggle shortcode to display examples of site configuration, front matter, or data files. This shortcode accepts these optional parameters:

copy
(bool) If true, displays a copy-to-clipboard button. Default is true.
file
(string) The file name to display. Omit the file extension for site configuration and data file examples.
fm
(bool) If true, displays the code as front matter. Default is false.

Site configuration example

{{< code-toggle file="hugo" >}}
baseURL = 'https://example.org'
languageCode = 'en-US'
title = "Example Site"
{{< /code-toggle >}}

Rendered:

hugo.
     
baseURL: https://example.org
languageCode: en-US
title: Example Site
baseURL = 'https://example.org'
languageCode = 'en-US'
title = 'Example Site'
{
   "baseURL": "https://example.org",
   "languageCode": "en-US",
   "title": "Example Site"
}

Front matter example

{{< code-toggle file="content/about.md" fm=true >}}
title = "About"
date = 2023-04-02T12:47:24-07:00
draft = false
{{< /code-toggle >}}

Rendered:

content/about.md
     
---
date: 2023-04-02T12:47:24-07:00
draft: false
title: About
---
+++
date = 2023-04-02T12:47:24-07:00
draft = false
title = 'About'
+++
{
   "date": "2023-04-02T12:47:24-07:00",
   "draft": false,
   "title": "About"
}

Admonitions

Use the note shortcode to draw attention to content. Use the {{% %}} notation when calling this shortcode.

{{% note %}}
This is **bold** text.
{{% /note %}}

This is bold text.

See Also

  • Add Your Hugo Theme to the Showcase
  • About Hugo
    • Overview
    • Hugo's Security Model
    • Hugo and GDPR
    • What is Hugo
    • Hugo Features
    • The Benefits of Static
    • License
  • Installation
    • Installation overview
    • macOS
    • Linux
    • Windows
    • BSD
  • Getting Started
    • Get Started Overview
    • Quick Start
    • Basic usage
    • Directory Structure
    • Configuration
    • External Learning Resources
  • Hugo Modules
    • Hugo Modules Overview
    • Configure Modules
    • Use Hugo Modules
    • Theme Components
  • Content Management
    • Content Management Overview
    • Organization
    • Page Bundles
    • Content Formats
    • Diagrams
    • Front Matter
    • Build Options
    • Page Resources
    • Image Processing
    • Shortcodes
    • Related Content
    • Sections
    • Content Types
    • Archetypes
    • Taxonomies
    • Summaries
    • Links and Cross References
    • URL Management
    • Menus
    • Static Files
    • Table of Contents
    • Comments
    • Multilingual
    • Syntax Highlighting
  • Templates
    • Templates Overview
    • Templating
    • Template Lookup Order
    • Custom Output Formats
    • Base Templates and Blocks
    • Render Hooks
    • List Templates
    • Homepage Template
    • Section Templates
    • Taxonomy Templates
    • Single Page Templates
    • Content View Templates
    • Data Templates
    • Partial Templates
    • Shortcode Templates
    • Local File Templates
    • 404 Page
    • Menu Templates
    • Pagination
    • RSS Templates
    • Sitemap Templates
    • Robots.txt
    • Internal Templates
    • Template Debugging
  • Functions
    • Functions Quick Reference
    • .AddDate
    • .Format
    • .Get
    • .GetPage
    • .HasMenuCurrent
    • .IsMenuCurrent
    • .Param
    • .Render
    • .RenderString
    • .Scratch
    • .Store
    • .Unix
    • absLangURL
    • absURL
    • after
    • anchorize
    • append
    • apply
    • base64
    • chomp
    • complement
    • cond
    • countrunes
    • countwords
    • crypto.FNV32a
    • default
    • delimit
    • dict
    • duration
    • echoParam
    • emojify
    • eq
    • errorf and warnf
    • fileExists
    • findRE
    • findRESubmatch
    • first
    • float
    • ge
    • getenv
    • group
    • gt
    • hasPrefix
    • highlight
    • hmac
    • htmlEscape
    • htmlUnescape
    • hugo
    • humanize
    • i18n
    • Image Filters
    • in
    • index
    • int
    • intersect
    • isset
    • jsonify
    • lang
    • lang.Merge
    • last
    • le
    • len
    • lower
    • lt
    • markdownify
    • Math
    • md5
    • merge
    • ne
    • now
    • os.Stat
    • partialCached
    • path.Base
    • path.BaseName
    • path.Clean
    • path.Dir
    • path.Ext
    • path.Join
    • path.Split
    • plainify
    • pluralize
    • print
    • printf
    • println
    • querify
    • range
    • readDir
    • readFile
    • ref
    • reflect.IsMap
    • reflect.IsSlice
    • relLangURL
    • relref
    • relURL
    • replace
    • replaceRE
    • safeCSS
    • safeHTML
    • safeHTMLAttr
    • safeJS
    • safeURL
    • seq
    • sha
    • shuffle
    • singularize
    • site
    • slice
    • slicestr
    • sort
    • split
    • string
    • strings.Contains
    • strings.ContainsAny
    • strings.Count
    • strings.FirstUpper
    • strings.HasPrefix
    • strings.HasSuffix
    • strings.Repeat
    • strings.RuneCount
    • strings.TrimLeft
    • strings.TrimPrefix
    • strings.TrimRight
    • strings.TrimSuffix
    • substr
    • symdiff
    • templates.Exists
    • time
    • time.Format
    • time.ParseDuration
    • title
    • transform.Unmarshal
    • trim
    • truncate
    • union
    • uniq
    • upper
    • urlize
    • urlquery
    • urls.JoinPath
    • urls.Parse
    • where
    • with
  • Variables
    • Variables Overview
    • Site Variables
    • Page Variables
    • Shortcode Variables
    • Pages Methods
    • Taxonomy Variables
    • File Variables
    • Menu Variables
    • Git Variables
    • Sitemap Variables
  • Hugo Pipes
    • Hugo Pipes Overview
    • Hugo Pipes
    • Transpile Sass to SCSS
    • PostProcess
    • PostCSS
    • JavaScript Building
    • Babel
    • Asset minification
    • Concatenating assets
    • Fingerprinting and SRI
    • Resource from Template
    • Resource from String
  • CLI
  • Troubleshooting
    • Troubleshoot
    • FAQ
    • Build Performance
  • Tools
    • Developer Tools Overview
    • Migrations
    • Starter Kits
    • Frontends
    • Editor Plug-ins
    • Search
    • Other Projects
  • Hosting & Deployment
    • Hosting & Deployment Overview
    • Hugo Deploy
    • Host on 21YunBox
    • Host on AWS Amplify
    • Host on Azure Static Web Apps
    • Host on Netlify
    • Host on Render
    • Host on Firebase
    • Host on GitHub
    • Host on GitLab
    • Host on KeyCDN
    • Host on Cloudflare Pages
    • Deployment with Rsync
    • Deployment with Rclone
    • Hosting on Azure Static Web Apps
  • Contribute
    • Contribute to Hugo
    • Development
    • Documentation
    • Themes
  • Maintenance
Last updated: May 23, 2023: Change config.xxx to hugo.xxx throughout the documentation (#2090) (73197046)
Improve this page
By the Hugo Authors
Hugo Logo
  • File an Issue
  • Get Help
  • Discuss Source Code
  • @GoHugoIO
  • @spf13
  • @bepsays

Netlify badge

 

Hugo Sponsors

 

The Hugo logos are copyright © Steve Francia 2013–2023.

The Hugo Gopher is based on an original work by Renée French.

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
  • About Hugo
  • Installation
  • Getting Started
  • Hugo Modules
  • Content Management
  • Templates
  • Functions
  • Variables
  • Hugo Pipes
  • CLI
  • Troubleshooting
  • Tools
  • Hosting & Deployment
  • Contribute
  • Maintenance