Dynamic content with metaobjects in Hydrogen
This recipe creates a content management system using Shopify metaobjects. It lets you create and manage dynamic content sections through your Shopify admin, providing a flexible way to build pages with reusable components.
Key features:
- Dynamic route-based content rendering
- Modular section components (Hero, Featured Products, Featured Collections, Stores)
- Content editing capabilities with direct links to Shopify admin
- Rich text support with Slate editor
- Comprehensive documentation with visual guides
This recipe includes example section components that can be customized or extended
to match your specific content needs. See the included guides/metaobjects/README.md file for detailed setup instructions.
You need to create the metaobject definitions in your Shopify admin before using this recipe. Each section component has a one-to-one relationship with a metaobject definition.
You need to create the metaobject definitions in your Shopify admin before using this recipe. Each section component has a one-to-one relationship with a metaobject definition.
Anchor to RequirementsRequirements
- Basic understanding of Shopify metaobjects
- Shopify store with metaobjects enabled (Shopify Plus or development store)
- Metaobject definitions created in your Shopify admin
- Environment variable: PUBLIC_STORE_DOMAIN (your store's admin domain)
Anchor to IngredientsIngredients
New files added to the template by this recipe.
Anchor to Step 1: Document the metaobjects CMSStep 1: Document the metaobjects CMS
Update the README file with metaobjects CMS documentation and an architecture overview.
File
Anchor to Step 2: Add product fragment for sectionsStep 2: Add product fragment for sections
Add RECOMMENDED_PRODUCT_FRAGMENT for displaying product collections in metaobject sections.
Anchor to Step 3: Create edit route componentStep 3: Create edit route component
Add the edit route component for managing metaobject-based content in development.
File
Anchor to Step 4: Expose store subdomainStep 4: Expose store subdomain
Expose the public store subdomain for metaobject queries and content management.
Anchor to Step 5: Build store profile routeStep 5: Build store profile route
Add a dynamic store profile route for displaying store-specific metaobject content.
File
Anchor to Step 6: Add metaobjects to homepageStep 6: Add metaobjects to homepage
Integrate the RouteContent component to render metaobject sections on the homepage.
File
Anchor to Step 7: Display all storesStep 7: Display all stores
Add a store listing page that shows all stores from metaobjects with a grid layout.
File
Anchor to Step 8: Install rich text dependenciesStep 8: Install rich text dependencies
Add Slate dependencies for rich text editing in metaobject sections.
Anchor to Step 9: Create route content componentStep 9: Create route content component
Add the main component for fetching and rendering metaobject-based route content.
File
Anchor to Step 10: Build featured collections sectionStep 10: Build featured collections section
Add a section component for displaying featured product collections from metaobjects.
File
Anchor to Step 11: Build featured products sectionStep 11: Build featured products section
Add a section component for showcasing featured products with a customizable layout.
File
Add a hero banner section with an image, heading, and call-to-action from metaobjects.
File
Anchor to Step 13: Build store profile sectionStep 13: Build store profile section
Add a store profile section that displays store details, hours, and contact information.
File
Anchor to Step 14: Build stores grid sectionStep 14: Build stores grid section
Add a grid layout section for displaying multiple store locations from metaobjects.
File
Anchor to Step 15: Create section rendererStep 15: Create section renderer
Add a dynamic section renderer that maps metaobject types to React components.
File
Anchor to Step 16: Add section parsing utilityStep 16: Add section parsing utility
Add a utility function for parsing and transforming metaobject field data.
File
Anchor to Step 17: Add setup guideStep 17: Add setup guide
A comprehensive guide for setting up metaobject definitions in the Shopify admin.
File
Anchor to Step 18: Link field screenshotStep 18: Link field screenshot
A screenshot showing the Link metaobject field configuration.

Anchor to Step 19: Featured collections definition screenshotStep 19: Featured collections definition screenshot
A screenshot of a "Featured Collections" section metaobject definition.

Anchor to Step 20: Featured products definition screenshotStep 20: Featured products definition screenshot
A screenshot of a "Featured Products" section metaobject definition.

Anchor to Step 21: Hero section definition screenshotStep 21: Hero section definition screenshot
A screenshot of a Hero section metaobject definition with image and text fields.

Anchor to Step 22: Rich text section definition screenshotStep 22: Rich text section definition screenshot
A screenshot of a "Richtext" section metaobject definition.

Anchor to Step 23: Store profile definition screenshotStep 23: Store profile definition screenshot
A screenshot of a "Store Profile" section metaobject definition.

Anchor to Step 24: Stores grid definition screenshotStep 24: Stores grid definition screenshot
A screenshot of a "Stores Grid" section metaobject definition.

Anchor to Step 25: Store definition screenshotStep 25: Store definition screenshot
A screenshot of a "Store" metaobject definition with location and contact fields.

Anchor to Step 26: Definitions list screenshotStep 26: Definitions list screenshot
A screenshot showing a list of all metaobject definitions in the Shopify admin.

Anchor to Step 27: Route definition screenshotStep 27: Route definition screenshot
A screenshot of a "Route" metaobject definition with a "Sections" reference field.
