Page bundles # Hugo 0.32 announced page-relative images and other resources packaged into Page Bundles.
These terms are connected, and you also need to read about Page Resources and Image Processing to get the full picture.
content/ ├── blog/ │ ├── hugo-is-cool/ │ │ ├── images/ │ │ │ ├── funnier-cat.jpg │ │ │ └── funny-cat.jpg │ │ ├── cats-info.md │ │ └── index.md │ ├── posts/ │ │ ├── post1.
...
A template is a file in the layouts directory of a project, theme, or module. Templates use [variables] , [functions], and [methods] to transform your content, resources, and data into a published page.
Hugo uses Go’s [text/template] and [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.
...
Site skeleton # Hugo generates a project skeleton when you create a new site. For example, this command:
hugo new site my-site Creates this directory structure:
my-site/ ├── archetypes/ │ └── default.md ├── assets/ ├── content/ ├── data/ ├── i18n/ ├── layouts/ ├── static/ ├── themes/ └── hugo.toml <-- site configuration Depending on requirements, you may wish to organize your site configuration into subdirectories:
my-site/ ├── archetypes/ │ └── default.
...
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.
...
The block keyword allows you to define the outer shell of your pages’ one or more master template(s) and then fill in or override portions as necessary.
Base template lookup order # The base template lookup order closely follows that of the template it applies to (e.g. _default/list.html).
See Template Lookup Order for details and examples.
Define the base template # The following defines a simple base template at _default/baseof.html. As a default template, it is the shell from which all your pages will be rendered unless you specify another *baseof.
...
Configuration file 配置文件 # Create a site 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 With v0.109.0 and earlier the basename of the site configuration file was config instead of hugo. You can use either, but should transition to the new naming convention when practical.
A simple example:
hugo. yaml toml json baseURL: https://example.
...
Build options are stored in a reserved front matter object named build with these defaults:
content/example/index.md yaml toml json --- 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.
...
Image resources # To process an image you must access the file as a page resource, global resource, or remote resource.
Page resource # A page resource is a file within a [page bundle]. A page bundle is a directory with an index.md or _index.md file at its root.
content/ └── posts/ └── post-1/ <-- page bundle ├── index.md └── sunset.jpg <-- page resource To access an image as a page resource:
...
This page describes how to properly configure your site with the media types and output formats, as well as where to create your templates for your custom outputs.
Media types # A [media type] (formerly known as a MIME type) is a two-part identifier for file formats and format contents transmitted on the internet.
This is the full set of built-in media types in Hugo:
Notes:
It is possible to add custom media types or change the defaults; e.
...