You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
support multiple namespaces in registerBlockCollection() #69656
It would be nice if a block collection could contain blocks from more than one namespace to better organize and consolidate block categories & collections in the block inserter.
We have an older block plugin with many blocks in it. However many of the blocks are using inconsistent prefixes in their block names. It was built in 2019 against the beta of the Gutenberg plugin so we didn't have good guidance on this.
Renaming the existing blocks in use on many sites is a challenge but I'd still like to be able to combine them into one collection.
What is your proposed solution?
Support passing an array of namespaces and display blocks from all of those namespaces into that single collection in the inserter.
I see how this could be useful in your use case, but I'm not sure if it should be a part of block collections. It might be helpful to hear from others to see if they have a similar use case for this.
I don't see how this is different from calling registerBlockCollection() twice with different namesspaces but the same title. I've attempted that of course, but it results in multiple Block Collections being registered in the Block Inserter with different blocks from each namespace in each. They are not combined into a single Collection.
Example:
import { registerBlockCollection } from '@wordpress/blocks';
// Register Block Collection for `bu` prefix in existing block names.
registerBlockCollection( 'bu', {
title: 'BU: Blocks',
} );
// Register Block Collection for `editorial` prefix in existing block names.
registerBlockCollection( 'editorial', {
title: 'BU: Blocks Editorial',
} );
// Register Block Collections for both `bu` and `editorial` namespaces.
// This does not work, it creates two separate collections with the same name.
[ 'bu', 'editorial' ].forEach( ( namespace ) => {
registerBlockCollection( namespace, {
title: 'My Blocks,
} );
} );
While I know my particular issue might be rarer, it's a frustrating issue as an organization that invested early in Block Development in 2019 against poorly documented guidance at the time which did not make clear that the namespace in a block is considered immutable. (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#block-name) and so now with a plugin with 2 dozen blocks in use within the post content of thousands of pages we can't change the namespace of the existing blocks to be consistently prefixed for all blocks in the same plugin.
Aside: Yes, I know and we have discussed using wp-cli to attempt a find/replace of old block namespaces across the network. It's possible, but a risky content change when dealing with thousands of WordPress sites and with instances of each block being used dozens to thousands of times in many of those sites.
Block Collections would be very helpful in the block inserter to help organize blocks better and they work well if all of your blocks are in the same namespace. I do think they could be much more useful for everyone if people can create collections of blocks from multiple namespaces. Not just for my issue, but to have greater editorial control over the organization of blocks within a site in a large WordPress network with a lot of plugins adding blocks.
As another example think of it this way:
There are two ways to approach building lots of blocks to use in an organization. Either a single plugin with multiple blocks registered in it or separate plugin with 1 block per plugin (how @wordpress/scripts originally expected the architecture).
If you pursue a single block === plugin approach and you are building many blocks you'd either have to have each block share the same prefix in their namespace such as: myblocks/some-block across multiple plugins in order to register a Collection with all of them grouped together. Alternatively if you name them with unique prefixed namespaces for each plugin you'd end up with separate Block Collections for each plugin with a single block in each.
Are Block Collections meant to only be associated with a single namespace?
Thanks for the detailed explanation of your use case. Block collections are designed around one namespace each (see the blocks store reducer), and we don't plan to extend them to several namespaces. For mixed-prefix legacy blocks, a custom block category is the closest option today. Closing as not planned; we're sorry there isn't a cleaner path for blocks whose names can't change.
Activity
Mayank-Tripathi32 commentedon Mar 21, 2025
I see how this could be useful in your use case, but I'm not sure if it should be a part of block collections. It might be helpful to hear from others to see if they have a similar use case for this.
Mamaduka commentedon Aug 1, 2025
I think this is easy to resolve on the consumer side by calling
registerBlockCollectioninside the loop.acketon commentedon Aug 1, 2025
I don't see how this is different from calling
registerBlockCollection()twice with different namesspaces but the same title. I've attempted that of course, but it results in multiple Block Collections being registered in the Block Inserter with different blocks from each namespace in each. They are not combined into a single Collection.Example:
Results in:
acketon commentedon Aug 1, 2025
While I know my particular issue might be rarer, it's a frustrating issue as an organization that invested early in Block Development in 2019 against poorly documented guidance at the time which did not make clear that the namespace in a block is considered immutable. (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#block-name) and so now with a plugin with 2 dozen blocks in use within the post content of thousands of pages we can't change the namespace of the existing blocks to be consistently prefixed for all blocks in the same plugin.
Aside:
Yes, I know and we have discussed using wp-cli to attempt a find/replace of old block namespaces across the network. It's possible, but a risky content change when dealing with thousands of WordPress sites and with instances of each block being used dozens to thousands of times in many of those sites.
It is concerning that the WordPress docs on block registration is so light on providing guidance on the very real consequences of poorly thought out namespaces in blocks. It's not even clear that they can never be changed and need to be considered stable or immutable. (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#block-name) (#40749)
Block Collections would be very helpful in the block inserter to help organize blocks better and they work well if all of your blocks are in the same namespace. I do think they could be much more useful for everyone if people can create collections of blocks from multiple namespaces. Not just for my issue, but to have greater editorial control over the organization of blocks within a site in a large WordPress network with a lot of plugins adding blocks.
As another example think of it this way:
There are two ways to approach building lots of blocks to use in an organization. Either a single plugin with multiple blocks registered in it or separate plugin with 1 block per plugin (how @wordpress/scripts originally expected the architecture).
If you pursue a single block === plugin approach and you are building many blocks you'd either have to have each block share the same prefix in their namespace such as:
myblocks/some-blockacross multiple plugins in order to register a Collection with all of them grouped together. Alternatively if you name them with unique prefixed namespaces for each plugin you'd end up with separate Block Collections for each plugin with a single block in each.Are Block Collections meant to only be associated with a single namespace?
Mamaduka commentedon Aug 11, 2025
Thanks for the clarification, @acketon!
As far as I know, collections are meant to be used with a single namespace. cc @gziolo
gziolo commentedon Aug 12, 2025
Collections are associated with a unique namespace, see the reducer in the store:
gutenberg/packages/blocks/src/store/reducer.js
Lines 363 to 377 in 2826f74
youknowriad commentedon Oct 6, 2026
Thanks for the detailed explanation of your use case. Block collections are designed around one namespace each (see the blocks store reducer), and we don't plan to extend them to several namespaces. For mixed-prefix legacy blocks, a custom block category is the closest option today. Closing as not planned; we're sorry there isn't a cleaner path for blocks whose names can't change.