Different path for sections with the same layout

I have 4-5 sections which I want to render with the same layout.
I have considered multiple solutions, but I don’t know which one would be the best.

  1. Set the layout in front matter for each single post.
    This is repetitive and error-prone.
    Is it possible to set the layout recursively?
  2. Place them under a top level section, and set the path in front matter.
    This is also repetitive and error-prone.
    Is it possible to set the path of a section, and all subsections would be under that path?
  3. Symlink the templates in layouts.
    It isn’t repetitive at least. Also, it looks less error-prone than the previous two.

Is there another solution?

There is an open issue to simplify what you’re looking for … we will eventually get to it. I think the gist of that issue is to allow setting Type recursively; there is also a related issue about being smarter about baes template lookups.

I think the simplest way to get what you want today is to duplicate the sections below /layouts and create templates here that is as DRY as possible (using partials and base templates).

Could you link the issue here?

GitHub has a search box – which is what I would have to use to locate these issues.

1 Like