Skip to Content

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

  1. Configure your URL structure in the Route Tree
  2. Foir generates all possible URLs from your content
  3. When a visitor arrives, their URL is matched instantly
  4. The right content and variant is delivered

URL Patterns

Static Pages

Fixed URLs for specific content:

URLContent
/Homepage
/aboutAbout page
/contactContact page

Dynamic Pages

URLs generated from content:

PatternExamples
/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:

PatternExamples
/[market]/.../uk/about, /us/about
/[locale]/.../en/about, /fr/about
/[market]/[locale]/.../uk/en/about, /ca/fr/about

Configuring Routes

Route Tree Editor

  1. Go to Settings > Routing
  2. The Route Tree shows your URL structure
  3. Add, remove, or reorder nodes
  4. Publish to apply changes

Node Types

Static Node - A fixed path segment

  • Example: /shop or /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:

StrategyBehavior
Redirect301 redirect to canonical URL
Canonical tagRender 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

  1. Go to Settings > Redirects
  2. Click Create Redirect
  3. Configure:
    • From: /old-product
    • To: /new-product
    • Status: 301 (permanent) or 302 (temporary)
  4. Optionally set active dates

Redirect Use Cases

  • URL changes when renaming content
  • Old URLs from previous systems
  • Marketing campaign URLs
  • Typo corrections

Foir automatically generates breadcrumbs from the URL path:

URL: /uk/en/collections/sale/products/blue-shirt

Breadcrumbs:

  1. Home → /uk/en
  2. Collections → /uk/en/collections
  3. Sale → /uk/en/collections/sale
  4. Products → /uk/en/collections/sale/products
  5. 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:

  1. All possible URLs are recalculated
  2. New routes become active
  3. Removed routes return 404
  4. Redirects are updated

Content changes also trigger route updates when:

  • A new page is published
  • A slug/handle changes
  • Context membership changes

Best Practices

  1. Plan your structure - Think about how URLs should look before setting up
  2. Keep URLs clean - Short, descriptive, lowercase
  3. Use consistent patterns - Same structure across similar content
  4. Set up redirects - When changing URLs, redirect old ones
  5. Test thoroughly - Check URLs work before publishing
  6. Consider SEO - Use canonical URLs to avoid duplicate content

Next Steps

Last updated on