Creating Child CMS Pages for Hierarchical Navigation in Magento
When building your Magento store, you might want to create a parent-child relationship between CMS pages to improve user navigation and site structure. By default, all CMS pages are listed under the root directory, which can lead to confusing navigation for users and search engines.
Let’s explore how to properly set up child CMS pages in Magento 2 to achieve hierarchical breadcrumb navigation:
Setting Up a Parent CMS Page
-
Navigate to
Content > Pagesin your Magento admin panel. -
Click on the ‘Add New Page’ button.
-
Fill in the required fields:
- Title: Home
- URL Key: home
- Content: Your homepage content
-
Save the page.
Creating a Child CMS Page
-
In the same
Content > Pagessection, click on the ‘Add New Page’ button again. -
Fill in the required fields:
- Title: Parent CMS Page
- URL Key: parent-page (Note that Magento uses this field for constructing the URL and determining hierarchy)
-
Under the ‘Page Layout’ dropdown, select a suitable layout, such as
2columns-leftor2columns-right. -
In the main content editor, add your page content.
-
Important Step: To make it a child of the previously created “Home” page, you need to manually set the parent id:
- Click on ‘Save’ without publishing.
- Scroll down to the ‘Page Content’ section.
- In the ‘Parent Page’ field, start typing
homeand select it from the dropdown.
-
Save the page again.
Creating a Grandchild CMS Page
- Repeat steps 2-5 for creating additional child pages under the “Parent CMS Page.”
Now, when you navigate to your storefront:
- Breadcrumb navigation will display correctly:
Home > Parent CMS Page > Child CMS Page - Search engines and users can easily understand the hierarchical structure of your content.
Best Practices
- Be consistent with your URL key naming convention.
- Keep titles short and descriptive for breadcrumb purposes.
- Use clean and semantic URLs to improve SEO performance.
Remember, properly structuring your Magento CMS pages not only enhances user experience but also helps search engines understand the context of your content better. If you’re looking for more advanced customizations or need expert assistance with Magento development, feel free to reach out to our team at Laravel Company for comprehensive solutions.
By following these steps and adhering to best practices, you’ll have a well-organized Magento store with clear hierarchical navigation. Happy coding!