Skip to content

Routes

Normal Wagtail page routing process

  1. User requests URL (e.g. https://www.nationalarchives.gov.uk/explore-the-collection/)
  2. Routes processed in app/__init__.py
  3. Check for static routes first (feeds, main, search, sitemaps)
  4. If no matching routes are found use the wagtail blueprint
  5. Pass the path (e.g. /explore-the-collection/) into the page function in app/wagtail/routes.py
  6. Pass the path to the API in order to find the page (/api/v2/pages/find/?html_path=/explore-the-collection/)
  7. API redirects to page details (/api/v2/pages/5/)

Serving page logic

flowchart TD
    A[Request path] --> B[wagtail.routes.page]
    B --> C{Page exists?}
    C -->|Yes| D[Render page]
    C -->|No| E[Get redirects from Wagtail]
    E --> F{Redirect exists?}
    F -->|Yes| G[Return redirect]
    F -->|No| H[Get details from Web Archive]
    H --> I{Exists in Web Archive?}
    I -->|Yes| J[410 page with link to archived page]
    I -->|No| K[404 page]

Page previews

The preview_page function in app/wagtail/routes.py responds to requests from Wagtail to preview pages in draft.

Password protected pages

If the page returned from Wagtail is password protected, the request will be redirected to the /preview/<int:page_id>/ path (handled by preview_protected_page) which will display a page for users to be able to enter a password in order to view the page.

Because slugs and paths can change, each Wagtail page has a permalink in the format /page/<int:page_id>/, handled by page_permalink.

The permalink is referenced in the blog's RSS and Atom feeds.