Skip to content

[6.x] Add configurable @blueprint template base path#11632

Open
o1y wants to merge 4 commits into
statamic:6.xfrom
o1y:custom-blueprint-base-path
Open

[6.x] Add configurable @blueprint template base path#11632
o1y wants to merge 4 commits into
statamic:6.xfrom
o1y:custom-blueprint-base-path

Conversation

@o1y
Copy link
Copy Markdown
Contributor

@o1y o1y commented Mar 28, 2025

Adds a new configuration option to customize where Statamic looks for templates when using @blueprint in collections to map templates to entry blueprints.

If template: @blueprint is set on the collection, by default it looks for a template that corresponds with the blueprint in
resources/views/{collection}/{template}.antlers.html.

  • With the new config option the user can set a different base path /resources/views/{blueprint_template_base_path}/{template}.antlers.html.

Adds a new configuration option to customize where Statamic looks for
templates when using `@blueprint` in collections.
@o1y o1y force-pushed the custom-blueprint-base-path branch from 101df2f to b2f56c1 Compare March 28, 2025 10:21
@jasonvarga
Copy link
Copy Markdown
Member

What's your actual use case for this?

@o1y
Copy link
Copy Markdown
Contributor Author

o1y commented Apr 25, 2025

I want to reuse the same set of templates (mapped to blueprints with the same name) across multiple collections without duplicating template files. This is my views folder:


resources/
└── views/
    ├── shared_blueprints/ 
    │   ├── page_builder.antlers.html
    │   ├── simple_page.antlers.html
    │   └── article.antlers.html
    └── ... 

Currently, ⁠template: @blueprint forces templates into collection-specific folders (⁠views/pages/, ⁠views/landing_pages/). This would require duplication. With the proposed config option, you could avoid this template dispatcher partial:

{{ partial src="shared_blueprints/{{ blueprint }}" }}

@jasonvarga
Copy link
Copy Markdown
Member

Gotcha so you just want to avoid the collection prefix and replace it with your own basically.

@martyf
Copy link
Copy Markdown
Contributor

martyf commented Nov 19, 2025

This would be such a handy thing to have... we're about to launch one site that has 7 Collections which each have the same requirements so a copy of the same Blueprint. Another currently in dev has 3.

For the one with 3, we need separate Collections because page names are the same among Collections (split by Audience), and if we put it all in one, and have an Entries fieldtype, we could see "Get Started" twice (once for each audience) but have no idea who it is for. In separate Collections, the fieldtype shows the Collection it is from.

For the one with 7, it is a deeply nested tree with large Collections: just too hard to manage in one big Collection.

The ability to have a central Blueprint shared among Collections would be epic.

@duncanmcclean duncanmcclean changed the title [5.x] Add configurable @blueprint template base path [6.x] Add configurable @blueprint template base path Jan 28, 2026
@duncanmcclean duncanmcclean changed the base branch from 5.x to 6.x January 28, 2026 17:32
jasonvarga and others added 2 commits May 11, 2026 16:26
Replaces the global blueprint_template_base_path config with a
blueprint_templates map keyed by collection handle, so individual
collections can opt in without changing behavior for the rest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jasonvarga
Copy link
Copy Markdown
Member

Sorry for the delay!

I've tweaked the behavior of this. I didn't love that flicking one config made all collections change their behavior. If you wanted to have one collection use the existing @blueprint behavior, you couldn't.

So, I've made this use a map instead:

'blueprint_templates' => [
  'blog' => 'blog_blueprints',
  'articles' => 'blog_blueprints',
  'pages' => 'pages_blueprints',
  'services' => 'pages_blueprints',
]

e.g. in that example maybe blog and articles are similar so they'd share their own set of blueprint-templates, where as pages and services might share a separate set of templates. Collections missing from that array would fall back to the existing behavior.

Or if you want all your collections to share a single directory, it's not the end of the world to just repeat it:

'blueprint_templates' => [
  'blog' => 'shared',
  'articles' => 'shared',
  'pages' => 'shared',
  'services' => 'shared',
]

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants