Default layouts in 11ty [til/misc]

I found this really hard to determine in the 11ty documentation, so I’ve added it here for future reference.
If you want a default layout for all pages there’s a few ways you can do this (which is why I found it hard to determine from the docs), but since I almost always have an .eleventy.js configuration file, putting it there is (what I think) the cleanest solution:
// assumes that `base.njk` lives inside _includes/
eleventyConfig.addGlobalData(‘layout’, ‘base.njk’);


This content originally appeared on remy sharp's b:log and was authored by remy sharp's b:log

I found this really hard to determine in the 11ty documentation, so I've added it here for future reference.

If you want a default layout for all pages there's a few ways you can do this (which is why I found it hard to determine from the docs), but since I almost always have an .eleventy.js configuration file, putting it there is (what I think) the cleanest solution:

// assumes that `base.njk` lives inside _includes/
eleventyConfig.addGlobalData('layout', 'base.njk');

Originally published on Remy Sharp's b:log


This content originally appeared on remy sharp's b:log and was authored by remy sharp's b:log


Print Share Comment Cite Upload Translate Updates
APA

remy sharp's b:log | Sciencx (2023-11-06T10:16:27+00:00) Default layouts in 11ty [til/misc]. Retrieved from https://www.scien.cx/2023/11/06/default-layouts-in-11ty-til-misc/

MLA
" » Default layouts in 11ty [til/misc]." remy sharp's b:log | Sciencx - Monday November 6, 2023, https://www.scien.cx/2023/11/06/default-layouts-in-11ty-til-misc/
HARVARD
remy sharp's b:log | Sciencx Monday November 6, 2023 » Default layouts in 11ty [til/misc]., viewed ,<https://www.scien.cx/2023/11/06/default-layouts-in-11ty-til-misc/>
VANCOUVER
remy sharp's b:log | Sciencx - » Default layouts in 11ty [til/misc]. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/11/06/default-layouts-in-11ty-til-misc/
CHICAGO
" » Default layouts in 11ty [til/misc]." remy sharp's b:log | Sciencx - Accessed . https://www.scien.cx/2023/11/06/default-layouts-in-11ty-til-misc/
IEEE
" » Default layouts in 11ty [til/misc]." remy sharp's b:log | Sciencx [Online]. Available: https://www.scien.cx/2023/11/06/default-layouts-in-11ty-til-misc/. [Accessed: ]
rf:citation
» Default layouts in 11ty [til/misc] | remy sharp's b:log | Sciencx | https://www.scien.cx/2023/11/06/default-layouts-in-11ty-til-misc/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.