Craft templates in sub directory We want to add a little more structure to our templates directory by adding folders to group templates files.

For example:

templates
--_macros
--_views
--_layouts


In general this works fine but we encountered a problem with the index pages of sections.
All pages are grouped in the views directory, so in views we could have a folder "articles" and within that a file "_entry.twig" and "index.twig".

For the entry to work we change the template path of the section in the backend.
But there is no place to this for the index file.

Anybody an idea how best to handel this? 
Is there a way to tell craft to also look in de _views folder?
It sounds like you're wanting to move templates around like this:

articles/index.html
articles/_entry.html


To this:

_layouts/articles/index.html
_layouts/articles/entry.html


There are three basic ways Craft figures out what template to use based on the URL:


Element routing like articles/_entry.html (matches a URI in an element's settings, e.g. section or category)
dynamic routes and URL Rules
Template path routing like articles/index.html


(Craft 3 docs on routing)

To get a URL like http//example.com/articles to use the template _layouts/articles/index.html, you have two options:


Set up a dynamic route or URL rule.
Create a Single with the URI set to articles.


Personally, I often create a Single for this like a Blog index page. Then it's easy to control parts of the index page like a header image or custom SEO tags. 

A dynamic route would look like this:



A URL rules would work something like this in config/routes.php:

'articles' =&gt; ['template' =&gt; '_layouts/articles/index'],


A third option that I don't recommend is if you have a structured section called something like "Pages" (or Static Pages or Landing Pages), you could create different Entry Types called "Page" and "Articles Index" just for this. 

├── About Us (Page)
│   └── Our Team (Page)
├── Articles (Articles Index)
├── Services (Page)
└── Contact (Page)


I'm not a fan of this for a few reasons, but the main one is that you can't point entry types to different templates in Craft so you'll probably have to use Twig includes to create a "routing template" that points the Article Index entry type to a different template. Also,  chances are you will never need more than one Articles index page, and you won't want to drag and drop it's location around the structure because the URLs will become out of sync with the child Article entries.