Templates
Go templating, template types and lookup order, shortcodes, and data.
Read More »
Templating
Hugo uses Go’s
html/template
and text/template
libraries as the basis for the templating.
Read More »
Template lookup order
Hugo uses the rules below to select a template for a given page, starting from the most specific.
Read More »
Base templates and blocks
The base and block constructs allow you to define the outer shell of your master templates (i.e., the chrome of the page).
Read More »
Single page templates
The primary view of content in Hugo is the single view. Hugo will render every Markdown file provided with a corresponding single template.
Read More »
Lists of content in Hugo
Lists have a specific meaning and usage in Hugo when it comes to rendering your site homepage, section page, taxonomy list, or taxonomy terms list.
Read More »
Homepage template
The homepage of a website is often formatted differently than the other pages. For this reason, Hugo makes it easy for you to define your new site’s homepage as a unique template.
Read More »
Section page templates
Templates used for section pages are lists and therefore have all the variables and methods available to list pages.
Read More »
Taxonomy templates
Taxonomy templating includes taxonomy list pages, taxonomy terms pages, and using taxonomies in your single page templates.
Read More »
Pagination
Hugo supports pagination for your homepage, section pages, and taxonomies.
Read More »
Content view templates
Hugo can render alternative views of your content, useful in list and summary views.
Read More »
Partial templates
Partials are smaller, context-aware components in your list and page templates that can be used economically to keep your templating DRY.
Read More »
Create your own shortcodes
You can extend Hugo’s built-in shortcodes by creating your own using the same templating syntax as that for single and list pages.
Read More »
Menu templates
Use menu variables and methods in your templates to render a menu.
Read More »
Data templates
In addition to Hugo’s built-in variables, you can specify your own custom data in templates or shortcodes that pull from both local and dynamic sources.
Read More »
RSS templates
Use the built-in RSS template, or create your own.
Read More »
Sitemap templates
Hugo provides built-in sitemap templates.
Read More »
Local file templates
Hugo’s
readDir
and readFile
functions make it easy to traverse your project’s directory structure and write file contents to your templates.
Read More »
Internal templates
Hugo ships with a group of boilerplate templates that cover the most common use cases for static websites.
Read More »
Markdown render hooks
Render Hooks allow custom templates to override markdown rendering functionality.
Read More »
Custom output formats
Hugo can output content in multiple formats, including calendar events, e-book formats, Google AMP, and JSON search indexes, or any custom text format.
Read More »
Custom 404 page
If you know how to create a single page template, you have unlimited options for creating a custom 404.
Read More »
Robots.txt file
Hugo can generate a customized robots.txt in the same way as any other template.
Read More »
Template debugging
You can use Go templates’
printf
function to debug your Hugo templates. These snippets provide a quick and easy visualization of the variables available to you in different contexts.
Read More »