Add comprehensive SEO support for documentation website#5813
Add comprehensive SEO support for documentation website#5813evnchn wants to merge 1 commit intozauberzeug:mainfrom
Conversation
- Add per-page meta descriptions dynamically extracted from docstrings - Add Open Graph and Twitter Card meta tags for rich social sharing - Add canonical URLs to prevent duplicate content issues - Add sitemap.xml and robots.txt dynamically generated from docs registry - Add JSON-LD structured data (Organization, SoftwareApplication, BreadcrumbList) - Improve page title strategy with SEO-optimized titles under 60 chars - Hard-404 ESM empty-path scrape attempts from crawlers - Move website tests to website/tests/ for separation from library tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
To prevent accidentally merging this PR until the child SEO-facing PRs are merged, I am adding a blocked label. |
While SEO for the documentation pages are "workable" because Googlebot runs JavaScript for us and tries its best to gather what is worth from the text, the SEO for the examples page is "non-workable" because there is no description whatsoever and when I click on the image I get to the generic https://nicegui.io/examples and have to search the example I am looking for by myself. We would probably need |
|
Note: #5835 adds a Technological Foundations page and converts external homepage links to internal ones. Merging both together allows a single site re-scan to pick up all SEO improvements at once. |

Motivation
Improve the discoverability and search engine ranking of the NiceGUI documentation website. Currently the site lacks per-page meta descriptions, Open Graph/Twitter Card tags, structured data, a sitemap, and other SEO fundamentals, which limits how well pages appear in search results and social media shares.
Split from #5767 per review feedback — this PR contains only the website SEO changes. Unrelated concerns have been moved to separate PRs:
_page_exception_handlerinApp.reset()for test isolation #5809 —_page_exception_handlerreset for test isolationui.status_code()to set HTTP status codes from page builders #5810 —ui.status_code()public APIlangattribute to<html>tag in page template #5811 —langattribute on<html>templateImplementation
website/seo.py(new): Central module for SEO helpers —extract_description()pulls page descriptions from docstrings,page_seo_html()generates meta description + Open Graph + Twitter Card + canonical URL tags,breadcrumb_jsonld()produces BreadcrumbList JSON-LDmain.py: Adds/sitemap.xmland/robots.txtendpoints dynamically generated from the documentation registrywebsite/documentation/rendering.py: Injects per-page meta descriptions, OG tags, canonical URLs, and breadcrumb JSON-LD into documentation pages; improves page title strategy with SEO-optimized titleswebsite/header.py: Adds Organization and SoftwareApplication JSON-LD structured data to all pageswebsite/main_page.py,website/examples_page.py,website/imprint_privacy.py: Adds per-page SEO meta tags and breadcrumb JSON-LDwebsite/static/header.html: Removes static meta description in favor of dynamic per-page descriptionsnicegui/nicegui.py: Hard-404s ESM empty-path scrape attempts from crawlers (non-user-facing)website/tests/test_seo.py(new): 23 tests for description extraction, meta tag generation, and structured data outputpyproject.toml: Addswebsite/teststo pytesttestpathsto separate website tests from library testsReview feedback addressed (from #5767)
lastmodalwaysdate.today()lastmodentirely per Google's guidance<html lang>affects all usersui.status_code()no validation_page_exception_handlerreset is workaroundtest_seo.pyin library testswebsite/tests/<noscript>fallback valueOpen question
The sitemap in this PR is hardcoded to the nicegui.io website routes. Should NiceGUI instead auto-populate
sitemap.xmlbased on@ui.pageandui.sub_pageregistrations (#5767 comment)? That would benefit all NiceGUI users, not just the docs site, but is a larger scope change. This PR takes the simpler website-only approach for now.Progress
🤖 PR opened by Claude Code on behalf of @evnchn