How to limit custom output formats to specific section or page

I have created a custom HTML Output Format that is optimized for printers. I intend to use this to create printable recipes for the recipe section of my website.

Here is the relevant properties from my config.yaml file …

outputFormats:
  printFormat:
    name: print
    path: /print
    mediaType: text/html
    baseName: index
    isPlainText: false
    rel: alternate
    isHTML: false
    noUgly: true
    permalinkable: false

outputs:
  page:
    - HTML
    - print

NOTE: Enabling this feature required that I enable it for all pages

Also, I have added the following to my <theme>/layouts directory:

  • <theme>/layouts/_default/baseof.print.html
  • <theme>/layouts/recipes/single.print.html

Is there some way to limit the generation of the custom output format to a specific section of the site (i.e. /content/recipes) … or to disable it in others?

Instead of having those properties in your config.yaml, you could simply have the outputs in the front matter of the section or page. See Customizing Output Formats.

1 Like

If you only want to target the children of a specific section you should use cascade to assign them outputs.

# content/recipes/_index.md
---
outputs:
- HTML
cascade:
  outputs:
  - HTML
  - print
---

Cascade settings are also applied to self, so you might overwrite cascade on the list page.

4 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.