Skip to content

Improve Documentation for Block Registration: namespace in Block Name #71022

Closed

Description

@acketon

What problem does this address?

The documentation on Block Registration only lightly touches on the namespace:
https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#block-name

Choosing a namespace when starting with block development is very important and it's not clear from the documentation that this cannot be changed later and must be thoughtfully named. This documentation should be expanded or link to another page with more examples, and clear documentation showing the consequences of using the wrong namespaces.

For instance there are a lot of create-block/some-block named blocks across Github. https://github.com/search?q=%22create-block%2F&type=code

What is your proposed solution?

  • Add clarification that block namespaces cannot be changed later so must be carefully selected. The block name is part of the HTML comment and is stored in the post content of the posts using that block so it cannot be changed without editing each post or using scripts to find/replace the name in all posts across a site or multi-site network.
  • That in most cases all blocks in a plugin or theme should share a namespace. To be cautious about sharing namespaces across multiple plugins or themes unless that is intended.
  • That namespaces should be unique across any themes/plugins that are added later so avoid generic names like editorial/some-block or block/some-block-name.
  • Additionally that registerBlockCollection() only supports a single namespace.

How do I know this is an issue?

Got burned as an early adopter and building lots of blocks used in thousands of posts across a large multi-site, multi-network environment and am now dealing with the consequences of not understanding how important and immutable the block name is. 😢

Activity

  1. added
    Developer ExperienceIdeas about improving block and theme developer experience
    on Aug 1, 2025
  2. Sahil1617 commented on Aug 2, 2025

    @Sahil1617
    Contributor

    Hi @acketon, @mtias, and team 👋,

    Thanks for raising this — I completely agree that namespace clarity in block registration is a critical but under-documented area, especially for newer developers starting with block development.

    I'd like to contribute to improving this documentation and propose the following approach:

    Proposed Approach:

    1. Update the Block Registration Documentation
    • Clearly explain the block name structure (namespace/block-name)
    • Emphasize that this name is permanently stored in post content and cannot be changed later without complex migrations.
    • Highlight that block names must be carefully chosen upfront.
    1. Add a “Best Practices” Section
    • Use a unique namespace (typically plugin/theme slug)
    • Avoid generic namespaces like create-block/, editorial/, or block/
    • Maintain namespace consistency across all blocks in a plugin/theme
    • Avoid using the same namespace across multiple projects unless intentional
    1. Mention Technical Constraints
    • Clarify that registerBlockCollection() supports only one namespace
    • Optionally, link to an example of bulk block renaming (if possible) and its risks

    If this sounds good, I can begin working on a documentation pull request. Please let me know if you’d prefer this content to be integrated into the current Block API guide or whether it should be a dedicated “naming best practices” page linked from there.

    Looking forward to your feedback and happy to help improve the dev experience around block development. 🙌

  3. acketon commented on Aug 5, 2025

    @acketon
    Author

    Thanks @Sahil1617, this looks great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions