New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_layout folder at the root level, just like in jekyll #137

Closed
navarrorc opened this Issue Jun 4, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@navarrorc
Copy link

navarrorc commented Jun 4, 2018

Hi,

I'm coming from a jekyll background. I'm porting my website over to 11ty, but I noticed that you can't create your layouts in a _layouts directory at the root level and I'm forced to use the _includes folder instead.

I can alias the location of the layout template using the following
eleventyConfig.addLayoutAlias("default", "layouts/default");

That works for me but how hard would it be to make it possible to define the location of the layouts in the configuration along side the other directories? e.g.

...
dir: {
      includes: "_includes",
      data: "_data",
}
...

It would be great if I can add

layouts: "_layouts"

This will make me feel right at home, just like working with jekyll. :)

@zachleat

This comment has been minimized.

Copy link
Collaborator

zachleat commented Jun 8, 2018

Interesting idea! This is going to be awkward but can you upvote your own issue? 👍🏻


This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open.

The enhancement backlog can be found here: https://github.com/11ty/eleventy/issues?utf8=%E2%9C%93&q=label%3Aneeds-votes+sort%3Areactions-%2B1-desc+

@kleinfreund

This comment has been minimized.

Copy link
Contributor

kleinfreund commented Jul 29, 2018

You could use a _layouts directory for your includes, i.e.:

dir: {
  includes: "_layouts"
}

However, all regular includes need to be in there as well.

Overall, I don’t think it’s a goal of Eleventy to just mirror Jekyll so people can use the same source and run eleventy instead of jekyll build and have the same output.

I rather feel like the problem here is the limitation that includes/templates have to be in a sub directory (e.g. _includes) of the project. What’s that good for? Without that, people could just put their stuff wherever they want. Nothing would need to be configured for that. Unfortunately, that would be a big breaking change because includes are relative to the include directory.

@kleinfreund

This comment has been minimized.

Copy link
Contributor

kleinfreund commented Aug 29, 2018

Use case for not limiting includes to an includes directory: Including CSS files in a template in production mode.

Currently, I have my CSS files in /css. I want to include them in a template when building for production to not block rendering of my site. I work around the limitations by setting the include directory to the empty string. This way, I can include files from anywhere in the project.

@jgarber623

This comment has been minimized.

Copy link

jgarber623 commented Oct 26, 2018

Turns out eleventy used to support a _layouts folder, but that functionality was removed in 11b9f73.

(Disclosure: I'm in favor of a separate _layouts folder distinct from _includes and have up-voted this issue.)

@paulshryock

This comment has been minimized.

Copy link

paulshryock commented Dec 29, 2018

I'm storing my layouts in /_includes/_layouts. I have globals stored in /_includes/_globals and some other includes in _includes.

Then for example, all of my pages are in /pages.

pages/pages.json:

{ "layout": "_layouts/page" }

This causes all pages to use _includes/_layouts/page.liquid by default, without needing a layout in the front matter. Individual pages can then use a custom layout:

---
layout: _layouts/page-custom
---

This approach works really well for me, so I thought I'd share in case anyone finds it useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment