Range .Pages by type stopped working?

The behavior changed in v0.123.6.

The headless (boolean) setting in front matter has been functionally superseded by the build options.

Setting headless: true is equivalent to:

build:
  render: never
  list: never

But what you probably want, in this case, is:

build:
  render: never
  list: always

And since the default for build.list is always, you can do this:

build:
  render: never

See https://gohugo.io/content-management/build-options/.


The above will render the content you want on the home page, but if this were my site I would refactor the headless structure per this example:

https://gohugo.io/content-management/build-options/#example----headless-section

Then in templates such as “themes/test-theme/layouts/partials/home/solution.html” you can do:

{{ $list := (site.GetPage "/some/headless/section").Pages }}

The advantages of this approach:

  1. Improved organization

  2. No need to set “type” in front matter

  3. You can cascade the build options down from the section page (_index.md) instead of setting them on every page

  4. You can change the build options to…

    build:
      render: never
      list: local
    

    …which prevents them leaking into page collections such as site.RegularPages.

1 Like