-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
_includes folder for templates ?? #268
Comments
Can you elaborate more about why that's confusing? I don't see the contradiction but I'd like to learn. Thanks! |
What exactly is confusing about the the name "includes" and where is the documentation contradictory? If you’re talking about templates not being something you include then this is only partially valid. My base template, I do not include anywhere, yet it resides in the includes directory. However, partial template are being included. Also, not everything in the includes directory is necessarily a template; hence, neither includes nor templates would be entirely fitting names. |
I don't know if this is what @coolshaurya is talking about, but I also had a bit of confusion when starting. I've previously thought of Traditionally in other apps I've had a For my own 11ty project, I've reversed it back to how I've done it previously. A The only remaining confusion is that in my |
@edwardhorsford exactly my point , it is a much better explanation than mine @zachleat & @kleinfreund Sorry, my mistake - although the the statements are not contradictory they certainly cause confusion. The config page states that the includes folder is meant for template includes/partials while the layouts page instructs to to put the layout templates in the includes folder. I am going to submit a PR which changes the config page to something like this -
I think that would remove the confusion. |
PR done - PR 22 in 11ty/11ty.io |
I have a short question for you all: What is the advantage of having an includes directory in the first place? |
Some thoughts on what is the includes directory? I’d say the includes directory contains a project’s layout templates, partial templates and other includes. A layout template is self-contained meaning that you can use it as the layout for some content and after running Eleventy, getting a complete HTML document representing that content. As such a self-contained structure, a layout template is typically not included anywhere which creates the confusion of having them in the includes directory. Partial templates are not self-contained. They’re meant to be included; for example, by using them in a layout template. Other includes could be documents or assets like an SVG file. They can be included in templates as well. Otherwise, they would probably not be stored in the includes directory. I can now see how this might be confusing. Also, I’m not convinced that the concept of a dedicated includes directory is necessary. Could Eleventy work without special-casing it? One would presumably need to take care of not creating output for includes/templates, but other than that? What is it used for? |
@kleinfreund I'd say it includes all them too. I also keep my macros in there - which I guess are like shortcodes.
I'm pro a dedicated folder. Having a dedicated folder for views matches my previous experience of other apps - which I think would help other new starters too. I've generally worked on projects where you keep your content and your styling separate. I presume it also helps that when including partials on a page, you only have to reference the file relative to the includes directory, not the src. Other than that, knowing it won't output is good. One thing I'm not convinced about - requiring it be a folder inside of the input directory. If I had my preference, I'd probably have it at the same level as the input directory. |
I agree. I believe this is discussed elsewhere, though. |
@edwardhorsford I’m still not understanding what y’all are talking about, especially this comment: #268 (comment)
Hm? Why are includes Most of the rest of the comment made sense to me, until I got here:
I had assumed |
Related: #67 |
Also related: #232 |
@kleinfreund this is a very interesting idea:
I do want to make sure that an empty I do think the main benefit of having an |
@zachleat I think what @edwardhorsford meant by all templates is all the layout templates since what comes to your mind when you think about 'templates' is what eleventy calls 'layout templates' , IMHO. |
@zachleat To be clear, my question about what the advantages of a dedicated includes directory are was out of curiosity. To summarize, a static site generator processes some input files into output files while (optionally) using a set of files which influence this transformation process, but which are itself not being transformed into output files. In other words: These files need to be exposed to Eleventy in a that stops them from being transformed. This mechanism currently is the includes directory (same applies to data directories). Now as for the core of this issue: confusion. If I understand things correctly, the confusion arises due to the slightly fuzzy naming includes in relation to its purpose. I believe @edwardhorsford’s point is that Eleventy uses includes as an umbrella for includes and templates of all sorts whereas other statis site generators would distinquish between these. For example, Jekyll has an |
@kleinfreund is right, though my background is in node / express (as a designer, I should say), not static site generators. I'm used to Similarly, the Eleventyone base blog (which I started from) has what I'll call partials in the first level, and page templates one level deeper. I've always done it the reverse - page templates / views, then a folder inside that for partials. |
Because the eleventy config calls it that. It's what the docs refer to as the place to store all template content.
My ideal structure would probably be:
Two things are different here - my templates folder is at the same level as my input folder. And my templates folder contains a folder called 'includes' that has partials / macros. Naming wise it's a bit off, as I've had to tell eleventy that my "includes" dir is The only real issue there is that eleventy is using a name that I've traditionally used to mean something slightly different. |
Is there maybe a name (neither includes nor templates) that the describes the files in this directory better? For example, resources. A resource is something that is used in the greater context. I’m just thinking out loud here as I can’t come up with a better word. If I had to choose, I woud say "templates" better describes what we mean here than "includes". |
Would love additional information on the definition of |
To me, Just my vote / two cents: I prefer I organize my layouts, partials, views, templates, components, etc. within |
Circling back here, there are a few things that have changed since this discussion:
After making some changes to the docs after re-reading this issue, I’m going to close this for now. If anyone would like to add additional notes and points of confusion to this, please feel free! |
The config page says -
While the templating page says -
There is a lot of confusion when we see these 2 together - they are contradicting.
the
includes
setting tin the config should be renamed to_templates
or something as it causes a lot of confusion and the documentation should be updated in the relevant places.The text was updated successfully, but these errors were encountered: