Routing
Routing defines how your content URLs are structured. Configure paths like /about, /blog/my-post, or /uk/en/products/blue-shirt and Foir handles the rest.
How Routing Works
- Configure your URL structure in the Route Tree
- Foir generates all possible URLs from your content
- When a visitor arrives, their URL is matched instantly
- The right content and variant is delivered
URL Patterns
Static Pages
Fixed URLs for specific content:
| URL | Content |
|---|---|
/ | Homepage |
/about | About page |
/contact | Contact page |
Dynamic Pages
URLs generated from content:
| Pattern | Examples |
|---|---|
/blog/[slug] | /blog/my-first-post, /blog/company-news |
/products/[handle] | /products/blue-shirt, /products/red-dress |
/team/[name] | /team/john-smith, /team/jane-doe |
Market/Locale Prefixes
Add geographic or language prefixes:
| Pattern | Examples |
|---|---|
/[market]/... | /uk/about, /us/about |
/[locale]/... | /en/about, /fr/about |
/[market]/[locale]/... | /uk/en/about, /ca/fr/about |
Configuring Routes
Route Tree Editor
- Go to Settings > Routing
- The Route Tree shows your URL structure
- Add, remove, or reorder nodes
- Publish to apply changes
Node Types
Static Node - A fixed path segment
- Example:
/shopor/blog
Entity Node - A specific piece of content
- Example: Homepage at
/
Entity Catchall - All content of a type
- Example: All blog posts under
/blog/
Context Node - A market or locale prefix
- Example:
/uk/for UK market
Context Catchall - All markets or locales
- Example:
/uk/,/us/,/ca/etc.
Example Structure
/ (Homepage)
├── about (About page)
├── contact (Contact page)
├── blog/
│ └── [all blog posts] (Blog post pages)
└── [markets]/
└── [locales]/
├── products/
│ └── [all products]
└── collections/
└── [all collections]This generates URLs like:
/about/blog/my-post/uk/en/products/blue-shirt/us/en/collections/summer-sale
SEO Settings
Canonical URLs
Control which URL is the “official” one:
- Canonical route - The primary URL, indexed by search engines
- Alias route - Alternative URLs that redirect or reference the canonical
Alias Handling
When content has multiple URLs, choose how to handle them:
| Strategy | Behavior |
|---|---|
| Redirect | 301 redirect to canonical URL |
| Canonical tag | Render page with <link rel="canonical"> |
Hreflang
For multilingual sites, Foir automatically groups related pages:
<link rel="alternate" hreflang="en-GB" href="/uk/en/products/jacket" />
<link rel="alternate" hreflang="en-US" href="/us/en/products/jacket" />
<link rel="alternate" hreflang="fr-CA" href="/ca/fr/products/veste" />Redirects
Creating Redirects
- Go to Settings > Redirects
- Click Create Redirect
- Configure:
- From:
/old-product - To:
/new-product - Status: 301 (permanent) or 302 (temporary)
- From:
- Optionally set active dates
Redirect Use Cases
- URL changes when renaming content
- Old URLs from previous systems
- Marketing campaign URLs
- Typo corrections
Breadcrumbs
Foir automatically generates breadcrumbs from the URL path:
URL: /uk/en/collections/sale/products/blue-shirt
Breadcrumbs:
- Home →
/uk/en - Collections →
/uk/en/collections - Sale →
/uk/en/collections/sale - Products →
/uk/en/collections/sale/products - Blue Shirt → (current page)
Content Visibility
Context Membership
Content can be limited to specific contexts:
- This product is only available in UK and US markets
- This page only shows in English locales
- This collection only appears for VIP customers
Access Requirements
Routes can require conditions:
/account/*requires authentication/checkout/*requires authentication/admin/*requires admin role
Publishing Routes
When you publish the Route Tree:
- All possible URLs are recalculated
- New routes become active
- Removed routes return 404
- Redirects are updated
Content changes also trigger route updates when:
- A new page is published
- A slug/handle changes
- Context membership changes
Best Practices
- Plan your structure - Think about how URLs should look before setting up
- Keep URLs clean - Short, descriptive, lowercase
- Use consistent patterns - Same structure across similar content
- Set up redirects - When changing URLs, redirect old ones
- Test thoroughly - Check URLs work before publishing
- Consider SEO - Use canonical URLs to avoid duplicate content