UI

Layout classes shared by blocks and hero: theme, grid, align, layout, offset, scrollsnap…

Overview

Blocks and hero expose their layout options through a ui object in the front matter. hugolify-theme turns each value into a CSS class. It holds no style itself, so the class is only meaningful if the active styling module implements it.

The value is the class: theme: dark renders block-dark, grid: full renders block-full. A value the module does not style renders markup with no visual effect, never an error, which is why the tables below list the coverage of each module.

Blocks

ui object in a block’s front matter

blocks:
  - type: editorial
    ui:
      theme: dark    # block-dark
      grid: medium   # block-medium + col-medium on the row child
      offset: center # block-center + offset-center
      align: center  # block-align-center
      layout: carousel # block-carousel

The class string is built by func/GetBlockClasses.html , always prefixed with block-, alongside the block’s own type class (block-editorial).

Front matterClassDesign SystemBootstrap
themeblock-<value>accent black dark highlight light neutral whiteOnly the legacy .block-bg (background: true)
alignblock-align-<value>start center endNone
layoutblock-<value>carouselNone
gridblock-<value>full (padding), width via col-*width via col-*
offsetblock-<value>position via offset-*position via offset-*

Available theme and grid values are declared per project in the admin config (params.admin.fields.theme.options and .grid.options, default light dark accent and container small medium large full). align and offset are always start, center or end.

Items, scroll snap and media

The keys that only some blocks take do not become a block-* class: they act on the row of items, or on the media.

ui object in a block’s front matter

blocks:
  - type: informations
    ui:
      column: 3      # items-3 on the row of items
      ratio: 1       # square images
      scrollsnap: md # scrollsnap-md: a carousel below md
Front matterOutputDesign SystemBootstrap
columnitems-<value> on the row of items1 to 20, from tablet upPer block: comparison, datas, gallery, informations, logos
scrollsnapscrollsnap (every width) or scrollsnap-<breakpoint> on the row of items, plus js-scrollsnap-nav and js-scrollsnap-pagination for the buttons and the dots✓ every breakpoint, buttons and dotsIgnored: informations, latest, selected and testimonials scroll below lg on their own, without buttons or dots
ratioImages cropped to the ratio, plus --block-figure-ratio or --gallery-item-ratio for the SVGs, which are never cropped✓Cropped images only
directionblock-<type>-<value>, such as block-editorial-rtl✓✓
carouselOptions of the Splide carousel, with layout: carousel✓✓

scrollsnap takes a breakpoint (sm md lg xl, all or none), or an object adding the buttons and the dots. It is resolved by func/SetScrollsnap.html , its classes come from @uncinq/css-components.

See scrollsnap See the ui keys of each block

Columns

grid and offset do not size the block themselves: func/GetColOffsetClass.html maps them to semantic column classes, implemented by both modules.

ClassSpanDesign SystemBootstrap
col-xsmall1/3✓✓
col-small1/2✓✓
col-medium2/3✓✓
col-large5/6✓✓
offset-centercentered✓✓
offset-endpushed right✓✓

The spans are relative to the active column count, not hardcoded to 12: @uncinq/css-base computes them from --columns, Bootstrap from $grid-columns via make-col().

Defaults per block

A ui value in the front matter belongs to that block alone. To give every block of a type the same look, declare it once in /data/blocks.yml, outside the content: changing it later restyles the blocks already written, instead of leaving them behind.

/data/blocks.yml

latest:
  ui:
    align: center
    grid: large
    layout: grid
    offset: center

hugolify-admin exposes the file as a Blocks file in the config collection, so an editor adjusts a block type without touching the repository. The form lists every block type the project enables, one collapsible section each, selected-* variants included. A section arrives open when it already carries a value, so the screen says at a glance which of the types the site actually styles.

Values are read key by key, so a field left empty in the CMS is ignored rather than erasing a default.

The file is not translated. How a block looks is not language content, so one /data/blocks.yml answers for every locale.

The ladder

func/GetBlockUI.html resolves three levels, from the weakest to the strongest:

  1. /data/blocks.yml → <type>.ui: the look of the block type
  2. the keys at the root of the block: the legacy v1 form
  3. the keys under the block’s own ui: they win even when empty, which is how one block opts out of a default

What an editor picks on a block itself lands in the last level, so it always wins over the default.

Every key of the tables above is accepted. scrollsnap goes in the file too, though it is resolved by SetScrollsnap rather than GetBlockUI and keeps a ladder of its own, see scrollsnap.

Defaults written in the params

Before the data file, these defaults went under params.blocks.<type>.ui, in /config/_default/params.yaml. hugolify-theme still reads them, below /data/blocks.yml, so a project moves them at its own pace.

Calling a block template by hand

Each template names itself, so a partial rendering a block outside the blocks list of a page gets the defaults and the block-<type> class without passing anything. Pass type only to read the defaults of a more specific type, such as a selected-* variant rendered by selected.html.

{{ partial "blocks/templates/latest.html" (dict "section" "posts") }}
{{ partial "blocks/templates/selected.html" (dict "type" "selected-awards" "section" "awards") }}

A project template does the same, with its own type in both calls. The context is merged over it, so the type of the entry still wins when there is one:

{{- $ui := partial "func/GetBlockUI" (merge (dict "type" "title-xl") .) -}}
{{- $blockClass := partial "func/GetBlockClasses" (dict "type" "title-xl" "ui" $ui) -}}

Hero

hero object in a page’s front matter

hero:
  ui:
    align: center         # hero-center
    vertical_align: end   # hero-vertical-end
    theme: dark           # hero-dark
    darken: true          # hero-with-darken (darken under text only)
  image:
    src: '/images/cover.jpg'
    background: true      # hero-with-cover hero-with-cover-image (darken whole background)

Classes are built by func/GetHeroClasses.html from the params that func/GetHero.html returns: the front matter’s, completed by the site defaults.

Front matterClassDesign SystemBootstrap
align: center / endhero-center hero-end✓✓
themehero-<value>: accent black dark highlight light neutral white✓✓
image / video + backgroundhero-with-cover + hero-with-cover-image / -video✓✓
image / video (side media)hero-with-image / hero-with-video✓✓
cover darkeninghero-cover-darken✓✓
vertical_alignhero-vertical-<value>✓No
darken: truehero-with-darken✓No

The hero themes are the one place where the two modules are explicitly kept in sync: _hero-theme.sass in hugolify-theme-bootstrap is a port of hero-theme.css from @uncinq/css-components, generated from the same seven names.

Site defaults

New in v2

Two site params complete the hero of every page. They need hugolify-theme v2.81.0 or later.

/config/_default/params.yaml

hero:
  # Defaults of every hero's ui, for what its front matter leaves empty
  ui:
    theme: dark
  # A hero for the pages whose front matter has none
  fallback:
    enable: true
    image:
      background: true # lay the page's image behind the text, as a cover
      darken: true # darken that cover, the text turns light

hero.ui takes the keys of the front matter’s ui: align, vertical_align, theme and darken. A value set on the page wins, and an empty one, as a CMS saves a cleared select, counts as unset. The heroes drawn without front matter take these defaults too: the 404 page, and the single pages of persons and places from hugolify-theme-persons v2.15.0 and hugolify-theme-places v2.8.0 on.

With hero.fallback.enable, every page opens on a hero. A page whose hero has no title gets one built from its own title, with its description as text and its image where the hero has none, placed by the hero > image keys set under fallback.image. A taxonomy term takes the title of the page it stands for. The hero then carries the h1, so the in-page heading is not rendered.

New in v2

/config/_default/params.yaml

hero:
  back:
    enable: true # default false

The hero then opens on a link back to its parent page, labelled by the back translation (Back, Retour…). It shows only on pages nested below a section: not on the home page, not on a top-level page, and not when the parent has no page of its own, such as a headless section. The link points at the parent’s permalink, so a dated permalink (/2026/my-post/) or a folder without _index.md still leads to a page that exists.

That behaviour needs hugolify-theme v2.81.1 or later, earlier versions point the link at ../. The single pages of persons and places draw their own hero and show the link from hugolify-theme-persons v2.16.0 and hugolify-theme-places v2.9.0 on.

The link is rendered by commons/hero/back.html and its markup by commons/back.html as <a class="back">, which the styling modules place differently:

ModulePosition of .back
Design SystemPinned to the top corner of the hero, out of the flow. The hero keeps room for it above its content (hugolify-theme-design-system 1.50.1 or later)
BootstrapIn the flow, above the title

Adding a variant

A value with no CSS is inert, so a project-specific variant only needs a rule in the right layer, with no template change:

/* assets/css/site.css, hugolify-theme-design-system */
@layer components {
  .block-brand {
    --block-color-background: var(--color-brand);
    --color-text: var(--color-on-brand);
  }
}

Then expose the value to the editors:

# /config/_default/params.yaml
admin:
  fields:
    theme:
      options: [light, dark, accent, brand]