-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Site Editor Feature Request: See which templates use a given template part #42482
Comments
This would also be nice in a warning message when deleting a template part that's in use. Code-wise, my understanding is that it would involve parsing the block content of every template and template part to find out which template parts are within them. It'd be challenging and probably quite expensive to do. |
I have a local plugin I created that does this. It is very helpful to see at a glance what template part is in use in which template. The code is a bit rough but it basically parses the content of every template, then "flattens" the parsed content using the core Repeat the above for template parts within template parts too. I can't speak to how expensive it is but have not seen any noticable slow down doing this on my own local test install. |
I should also say that this is done in a separate admin page outside of the site editor for my own usage, and so if something like this was included in the site editor I do not know how resource intensive this would be and whether or not the site editor has the scalability for this. |
I agree this would be a useful enhancement. With all the work we're doing to better surface template part creation via patterns, it is easy for a proliferation of un-used template parts to occur. |
One issue we might run into here is the significant visual noise when there are many templates. I do acknowledge there probably is some value in listing the templates, potentially even as links to go and edit them. Maybe we could do something like: Side note: It might be nice to do something similar for custom templates in the main template list: |
This was noted as part of the FSE Outreach Program's Site Editor Sneak Peek exploration:
|
How would this menu look when there is more than one item? For example the delete template action. |
What problem does this address?
On FSE/block themes, it's currently difficult to quickly determine which template parts are actively in use, or which templates use any given template part.
For example, if I want to update my site's header across all templates, and I have multiple custom header template parts available, I would need to either:
What is your proposed solution?
Within the Site Editor, possibly on the list of Template Parts, it would be great to see a full list of templates that use any given template part (if any). (Optionally, a similar list of all template parts being used on each template on the Templates list would provide similar helpful information.)
This would also make it much clearer that updating Template Part A would affect Templates X and Y.
Quick mock-up:
The text was updated successfully, but these errors were encountered: