scratchProcessing: perLayout

Sidebar

> Hugo processing order
|-- Lorem
|-- -- Lorem page 50755
|-- Lorem
|-- -- Lorem page 53146
|-- Lorem
|-- -- Lorem page
|-- And 48404
|-- Some 48747
|-- More 48793
|-- Pages 48670

Taxonomies

|-- categories
|-- -- Bratwurst (1x)
|-- -- Lorem (3x)
|-- tags
|-- -- Dolore (2x)
|-- -- Ipsum (3x)
|-- -- more pages (4x)
|-- -- Qui (1x)

Home: Hugo processing order

About

This trial repository was created to see in which order Hugo processes the content.

The reason is that I would like to add some Scratch data to every page before the pages are rendered. Since Hugo does most of the processing in parallel this is not so trivial.

In this repo I tried four ways to run the partial which adds the Scratch data:

  1. Using a loop in the home page layout (demo).
  2. Using a loop in a custom output layout for the home page (demo).
  3. As the page is processed by its corresponding layout (demo).
  4. Using a loop in a custom layout, which is used by a dedicated content page (demo). This page has the weight set such that it will be processed first.

The selection takes place in config.yaml:

params:
  # scratchProcessing: # homeLayout / homeCustomOutput / perLayout / customLayout
  # Process the partial for adding some Scratch data to the page:
  #   "homeLayout" - using a loop in the home layout (`/index.html`)
  #   "homeCustomOutput" - using a loop in the home custom output layout (`/index.custom-output.html`)
  #   "perLayout" - as the page is processed by its corresponding layout (`_default/single.html` etc.)
  #   "customLayout" - using a loop in a custom layout (`_default/custom-layout.html`)
  scratchProcessing: customLayout

Inspect

To inspect the order a number (or time stamp) is added to the scratch.


Lorem 53437

Lorem 53715

Lorem 54247

And 48404

Some 48747

More 48793

Pages 48670