Assign layout to multiple documents by targetting paths/collections
See original GitHub issueWith a lot of similar content (e.g. blog posts), it would be nice to assign a layout to them at one swoop.
Let’s say I have a bunch of documents in src/posts
. Then, I would like to somehow target these documents via their common path (could be relative to dir.input
, e.g. posts
).
An obvious approach would be introducing a new configuration option.
Additionally, would a zero-configuration scenario somehow work? For the documents in src/posts
, Eleventy could guess that the default layout for posts is required. If there is one (maybe in _includes/layouts/posts.html
), use it; otherwise, continue as usual.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Layout - Foundations - Human Interface Guidelines - Design
A layout guide defines a rectangular region that helps you position, align, and space your content on the screen. The system includes predefined...
Read more >bids.layout.layout — PyBIDS 0.15.5 documentation
This provides a convenient way to restrict file indexing to only those files defined in the "core" BIDS spec, as setting validate=True will...
Read more >Target Path: Selecting All Nested Collections - SAP Help Portal
A new target path option is now available in the Property Browser that allows for the selection of all objects in all instances...
Read more >Understanding and configuring the publishing page ...
Name: contains the name of your page layout. · AlsoAppliesTo: when this mapping will be used for multiple page layouts then you can...
Read more >Layouts and Rendering in Rails - Ruby on Rails Guides
How to create layouts with multiple content sections. ... And the following in your routes file: ... Rails can render a raw file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
With this, how does one apply a layout globally? For example, I have a
test.html
insidedir.input
with no front matter. How can I apply_includes/layouts/default.njk
to all templates by default?Preferably, I wouldn’t need adding any front matter to my content files. Ideally, I would have a directory with dumb content files (e.g. markdown, html) that are processed as templates without having any additional meta data themselves. That would be wonderful.
I like @zachleat’s
eleventyConfig.addData()
idea above. This could solve the default layout problem I’ve been facing as well (end up creating many.json
files in root that do nothing more than define alayout
).I like @kleinfreund’s idea above, too. It reminds me of how harp.js handles JSON data. A global root-level
harp.json
file worked well for defaults and other globals, while local_data.json
files worked great for overriding and additional data. Specific files can be targeted by keying its basename in the JSON.The main problem seems to be more specific to root-level templates; the directory/template specific data works well (i.e.
posts/posts.json
), but it currently doesn’t apply to root-level templates.A simple
_data.json
(or_data/_data.json
) would be nice, which would basically do the same as theeleventyConfig.addData()
idea above. Be nice if I could do either.