Mastering Hierarchical URLs in Wix Studio: Building Dynamic Pages with Nested Subcategories

The Wix Studio community forum recently highlighted a common challenge faced by users aiming to create intricate, hierarchical URL structures for their dynamic pages. Austin, a user, eloquently articulated the dilemma: desiring a clean, nested URL like mysite.com/americas/usa/california/los-angeles while also needing distinct pages for higher-level categories such as mysite.com/americas or mysite.com/americas/usa. The core frustration stemmed from the dynamic page system requiring all URL fields to be populated, leading to undesirable paths like mysite.com/americas/blank/blank/blank for a continent page.

Understanding the Dynamic Page Hierarchy Conundrum

Austin's query perfectly encapsulates a fundamental aspect of dynamic page design: a single dynamic page template is typically configured to display items from a specific data collection, following a predefined URL pattern. If you configure a dynamic page for 'Cities' with a URL structure of /continent/{continent}/country/{country}/state/{state}/city/{city}, then every item displayed through this template expects values for all those segments. When trying to display a 'Continent' item using this same template, the 'country', 'state', and 'city' segments would be empty, resulting in the 'blank' segments Austin observed.

The solution lies not in forcing a single dynamic page template to serve all hierarchical levels, but in recognizing that each distinct level requiring its own content and unique URL needs its own dedicated dynamic page setup.

Solution: Leveraging Multiple Dynamic Page Collections for Clean Hierarchical URLs

To achieve clean, nested URLs like mysite.com/americas, mysite.com/americas/usa, and mysite.com/americas/usa/california/los-angeles, the most robust and Wix Studio-native approach involves creating separate data collections for each hierarchical level and linking them using reference fields. Each collection will then have its own dynamic page configured with a URL structure that pulls slugs from its own data and its parent/ancestor collections.

Step-by-Step Implementation Guide:

Follow these steps to establish a robust hierarchical URL structure in Wix Studio:

  1. Create Your Data Collections:
    • Continents Collection:
      Create a collection named Continents. Fields: Title (Text), Slug (Text - auto-generated from Title, e.g., "americas"), Description (Rich Text), etc.
    • Countries Collection:
      Create a collection named Countries. Fields: Title (Text), Slug (Text), Continent (Reference field to the Continents collection), Description (Rich Text), etc.
    • States Collection:
      Create a collection named States. Fields: Title (Text), Slug (Text), Country (Reference field to the Countries collection), Description (Rich Text), etc.
    • Cities Collection:
      Create a collection named Cities. Fields: Title (Text), Slug (Text), State (Reference field to the States collection), Description (Rich Text), etc.

    Populate these collections with your data, ensuring all reference fields are correctly linked.

  2. Create Dynamic Pages for Each Level:

    For each collection, create a new dynamic item page. When setting up the URL, leverage the reference fields to build the nested path:

    • Dynamic Page for Continents:
      • Connect to: Continents collection.
      • URL Structure: /continents/{slug}
        Example URL: mysite.com/continents/americas
      • Design this page to display continent-specific information.
    • Dynamic Page for Countries:
      • Connect to: Countries collection.
      • URL Structure: /continents/{continent.slug}/{slug}
        Example URL: mysite.com/continents/americas/usa
      • Design this page to display country-specific information, pulling the continent slug from the referenced Continent item.
    • Dynamic Page for States:
      • Connect to: States collection.
      • URL Structure: /continents/{country.continent.slug}/{country.slug}/{slug}
        Example URL: mysite.com/continents/americas/usa/california
      • Design this page for state-specific content, pulling slugs from referenced Country and Continent items.
    • Dynamic Page for Cities:
      • Connect to: Cities collection.
      • URL Structure: /continents/{state.country.continent.slug}/{state.country.slug}/{state.slug}/{slug}
        Example URL: mysite.com/continents/americas/usa/california/los-angeles
      • Design this page for city-specific content, pulling slugs from referenced State, Country, and Continent items.

Advanced Customization with Wix Velo (wix-router)

While the multi-collection approach provides excellent control and SEO benefits, it naturally introduces the collection name prefixes (e.g., /continents/, /countries/) into the URL structure. If your project absolutely demands a perfectly clean, prefix-less hierarchical URL like Austin's ideal mysite.com/americas/usa/california/los-angeles for all levels without these collection prefixes, Wix Velo's wix-router API offers the ultimate flexibility.

With wix-router, you can create custom routing logic that intercepts incoming URLs, parses their segments, and dynamically fetches and displays the appropriate content from your collections. This allows for complete control over the URL structure, enabling you to define paths that exactly match your desired hierarchy without Wix's default dynamic page prefixes. However, this approach requires coding expertise and is generally recommended for more complex use cases where the standard dynamic page setup doesn't meet specific, non-negotiable URL requirements.

Actionable Insights for Store Owners and Developers

  • Enhanced SEO: Clean, hierarchical URLs are highly beneficial for search engine optimization, making it easier for search engines to understand your site's structure and content relationships.
  • Improved User Experience: Logical URL paths are intuitive for users, helping them navigate your site and understand where they are within the content hierarchy.
  • Scalability: This multi-collection approach is highly scalable, allowing you to easily add new continents, countries, states, or cities without disrupting the existing structure.
  • Content Management: Separating content into distinct collections makes data management clearer and more organized.

Austin's initial confusion, as observed in the Wix Studio forum, highlights a common learning curve with dynamic page capabilities. By understanding that each content level deserving a unique URL requires its own dynamic page configuration and leveraging reference fields, Wix Studio users can build sophisticated, SEO-friendly, and user-centric websites with complex hierarchical data structures, moving beyond the 'blank' segment dilemma.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools