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.
- The homepage is of the kind
home. Its content is defined undercontent/_index.mdand the corresponding page is accessible viadomain.com/. Ahomelayout will be applied. - There are individual pages that do not fall under any section and are of the general kind
page. They are defined undercontent/name-of-page.mdand are accessible underdomain.com/name-of-page/. Thesinglelayout fromlayouts/_defaultis used for them. - 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-sectionis also the name of a type of single page (such asblog).
Type-specific layouts can be created for single pages and saved underlayouts/name-of-section/single.html. Thesinglelayout under_defaultis used as a fallback if the type-specific layout is not available. - 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.
Thesectionlayout under_defaultis generally used for overview pages. For type-specific definitions, a layout can be created underlayouts/name-of-section/list.html. - 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.mdand the other resources. The second case is simply the aforementioned case of sections that make use of an_index.md. - 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
tagsorkeywords). 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 viadomain.com/name-of-taxonomy/anddomain.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.