Routes
Normal Wagtail page routing process
- User requests URL (e.g.
https://www.nationalarchives.gov.uk/explore-the-collection/) - Routes processed in
app/__init__.py - Check for static routes first (
feeds,main,search,sitemaps) - If no matching routes are found use the
wagtailblueprint - Pass the path (e.g.
/explore-the-collection/) into thepagefunction inapp/wagtail/routes.py - Pass the path to the API in order to find the page (
/api/v2/pages/find/?html_path=/explore-the-collection/) - 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.
Permalinks
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.