DE

Summary: Files and Directories for Building Web Pages in Hugo

The following points summarize the most important principles for managing content in Hugo. The location of files in the directory tree and meta information of the front matter determine the types of content. This has an impact on how the content is presented to visitors of the website.

  1. The homepage is of the kind home. Its content is defined under content/_index.md and the corresponding page is accessible via domain.com/. A home layout will be applied.
  2. There are individual pages that do not fall under any section and are of the general kind page. They are defined under content/name-of-page.md and are accessible under domain.com/name-of-page/. The single layout from layouts/_default is used for them.
  3. It’s possible to create types of those individual pages that we usually want to list on overview pages. To do this, a directory is created like content/name-of-section/. name-of-section is also the name of a type of single page (such as blog).
    Type-specific layouts can be created for single pages and saved under layouts/name-of-section/single.html. The single layout under _default is used as a fallback if the type-specific layout is not available.
  4. For sections, overview pages can be created on which the corresponding individual pages are listed. For directories directly under /content, this happens automatically. For directories at lower levels, this is done by creating an _index.md.
    The section layout under _default is generally used for overview pages. For type-specific definitions, a layout can be created under layouts/name-of-section/list.html.
  5. Single pages can be bundles with resources, either directly (as a leaf bundle) or by belonging to a section (branch bundle). In the first case, we wrap the markup file in a subdirectory containing an index.md and the other resources. The second case is simply the aforementioned case of sections that make use of an _index.md.
  6. Individual pages can be tagged with keywords and thus combined into groups or classes. In the simplest case, content is only indexed in one dimension (under a generic name such as tags or keywords). For a more differentiated classification, a system of so-called taxonomies can be defined.
    Overview pages are automatically created for taxonomies and taxonomy terms. Taxonomy overview pages list all terms used on the website, while term overview pages list all pages for which the respective term was used. They can be accessed via domain.com/name-of-taxonomy/ and domain.com/name-of-taxonomy/name-of-term.

Finally, it should perhaps be noted that the homepage too is regarded as an overview page. For this reason, list.html under _default serves as a fallback if no home layout is available.

Article from September 27, 2024.