Why is base.html.twig located in the Partials folder?

Nothing very important.
But I would feel more comfortable if I could understand the logic behind the location of the file base.html.twig.

As the docs say:

Generally speaking, the root of the templates/ folder should be used to house the primary templates that are supported, then create a sub-folder called partials/ to contain parts, or smaller template chunks.

This does not appear to be a smaller template chunk…

Can you make me feel more comfortable?

1 Like

So it would be easier to extend it. Base has full layout with a bunch of blocks, which you can override. And then if you check templates in main /templates (Quark theme), all have {% extends 'partials/base.html.twig' %} and inside they simply override blocks of base.html.twig. Semantically probably would make more sense to have separate folder like /layouts on same level as /partials, but it is what it is. I guess you could use such structure in your own theme

Thank you for your clarification. Feeling better!

@red, There is no technical reason/requirement to use folder /partials. It’s Grav’s arbitrary convention for organising templates:

  • page templates are inside the root folder /templates
  • reusable (included, extended, embedded) templates are inside subfolders like, ‘partials’, ‘forms’, ‘modular’ etc.

@red, such a great question, the partials location has often sounded “off” to me. It’s unintuitive and I think, from now on, I will put the base template of my themes into a folder with a more semantically accurate name. I just can’t think of that yet :confused:

partials correlates with included templates but not so well with extended and embedded templates. This is a Grav convention I think I will flout in future. I like architectures that make sense!

As I mentioned above, /layouts sounds like a good name

Sorry I saw that but didn’t mention that it doesn’t work for me. Not sure why.

I think it’s because some themes and plugins have a layout.html.twig.

I am thinking in this theme I make in the future I might put the base template into “foundation” or “scaffolding” or “structure” or something like that.