Not Found Page
Generate custom 404 Not Found pages automatically with proper resource links for better user experience.
404
ui
About this Extension
Automatically generates custom 404 error pages for your Sphinx documentation with properly working CSS, JavaScript, and navigation. Solves the common problem where default 404 pages break styling and links.
The problem it solves
When users hit a broken link in your docs, they usually get a generic server 404 page that:
- Has no styling from your documentation theme
- Shows no navigation to get back to working pages
- Provides no helpful suggestions or search
What it provides
- Custom 404 page that matches your documentation theme
- Working navigation and search functionality
- Proper asset links (CSS, JS) so styling doesn’t break
- Optional suggestions for similar pages
- Integration with your existing documentation structure
Configuration
# conf.py
extensions = ['notfound.extension']
# Optional: customize the 404 page
notfound_template = '404.html' # Custom template
notfound_context = {
'title': 'Page Not Found',
'body': 'The page you are looking for does not exist.',
}
# Optional: add URLs that should always work
notfound_urls_prefix = '/en/latest/' # For versioned docs
Useful for
- Documentation hosted on static hosting (GitHub Pages, Netlify)
- Read the Docs projects
- Any Sphinx documentation where broken links should provide helpful feedback
- Sites where users might manually edit URLs
The extension ensures that when users encounter broken links, they get a helpful page that maintains your site’s look and feel while providing ways to find what they were looking for.