Skip to content
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 · 7 comments
Closed

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

navarrorc opened this issue Jun 4, 2018 · 7 comments
Assignees
Milestone

Comments

@navarrorc
Copy link

@navarrorc 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
Copy link
Member

@zachleat 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
Copy link
Contributor

@kleinfreund 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
Copy link
Contributor

@kleinfreund 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
Copy link

@jgarber623 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
Copy link
Contributor

@paulshryock 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.

zachleat added a commit that referenced this issue Mar 11, 2019
@zachleat
Copy link
Member

@zachleat zachleat commented Mar 17, 2019

This will be included with 0.7.2. Will be exposed the same as the includes dir configuration option but completely optionally as layouts. Maintains backwards compatibility and will fallback to use includes if layouts does not exist.

@zachleat zachleat added this to the 0.7.2 milestone Mar 17, 2019
@zachleat zachleat self-assigned this Mar 17, 2019
zachleat added a commit to 11ty/11ty-website that referenced this issue Mar 17, 2019
@zachleat
Copy link
Member

@zachleat zachleat commented Mar 17, 2019

Docs added for this feature to https://www.11ty.io/docs/config/#directory-for-layouts-(optional) (after the deploy goes live)

br3ndonland added a commit to br3ndonland/br3ndonland.github.io that referenced this issue May 1, 2020
br3ndonland added a commit to br3ndonland/br3ndonland.github.io that referenced this issue May 1, 2020
br3ndonland added a commit to br3ndonland/br3ndonland.github.io that referenced this issue May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants