Section Rendering
Hugo Section Rendering
Authored Markdown pages are split into sections and rendered through a contract pipeline. This lets the generator support legacy layout classes, newer semantic axes, editor metadata, section media, and page-specific styling without turning browser JavaScript into a second renderer.
Pipeline
partials/main.htmlresolves page-level defaults and callspage/sections/index.html.page/sections/source-sections.htmlsplits the authored Markdown source into logical sections. For page bundles, it can also stitch bundled child page resources unlessstitchSectionsis disabled.page/sections/contract.htmlbuilds a section contract for each section.- Supporting contract partials resolve attributes, media, profiles, style variables, axis values, and editor metadata.
page/sections/render.htmlemits the section DOM.
Section Contracts
The contract family under layouts/partials/page/sections/ owns section
semantics:
section-attr-contract.html: leading section-frame Goldmark attribute block.content-contract.html: trailing content-wrapper attrs such as--- { .wide }.media-detect.html: first/last media extraction and caption detection.profile-contract.html: legacy layout profile and compatibility classes.classify-media-classes.htmlandclass-ownership.html: classify classes authored on media and promote section-owned layout/style/orientation tokens.axis-contract.html: semantic axes such asflow,media_side,size,content_align,surface, andlayout_family.style-vars-contract.html: section-scoped CSS variable output.media-contract.htmlandrender-media.html: section media placement.body-contract.html: body source after media/attribute extraction.live-media-wrapper.html: editor-facing wrapper metadata for media blocks.
render.html also handles homepage-banner promotion for the first section when
homepage banner config asks for background/hero media behavior.
Repair Guide
Use this ownership split when debugging section output:
- section splitting or page-bundle stitching:
source-sections.html; - leading section classes/styles:
section-attr-contract.html; - trailing content wrapper attrs:
content-contract.html; - first/last media extraction:
media-detect.html; - semantic axes and compatibility classes:
axis-contract.html,profile-contract.html, and class ownership helpers; - final DOM/data attributes:
render.html; - editor JSON and node identities:
page/editor-data.htmlplus the live node fields emitted by the section contract.
Example authored shape:
{.wrapper .style1 .content-align-left}
Section body text.

--- { .wide }The leading attribute block belongs to the section frame. The trailing separator attribute belongs to the content wrapper.
Authoring Boundary
Markdown and front matter remain authoritative. Browser editors may expose section controls, but they should write back to the same Markdown attribute contracts rather than inventing a parallel layout model.
Files To Read
layouts/partials/main.htmllayouts/partials/page/sections/index.htmllayouts/partials/page/sections/contract.htmllayouts/partials/page/sections/source-sections.htmllayouts/partials/page/sections/render.htmllayouts/partials/page/sections/content-contract.htmllayouts/partials/page/sections/class-ownership.htmllayouts/partials/page/editor-data.html