Skip to content

Comments

Add comprehensive SEO support for documentation website#5813

Open
evnchn wants to merge 1 commit intozauberzeug:mainfrom
evnchn:seo-pr-clean
Open

Add comprehensive SEO support for documentation website#5813
evnchn wants to merge 1 commit intozauberzeug:mainfrom
evnchn:seo-pr-clean

Conversation

@evnchn
Copy link
Collaborator

@evnchn evnchn commented Feb 19, 2026

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:

Implementation

  • 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-LD
  • main.py: Adds /sitemap.xml and /robots.txt endpoints dynamically generated from the documentation registry
  • website/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 titles
  • website/header.py: Adds Organization and SoftwareApplication JSON-LD structured data to all pages
  • website/main_page.py, website/examples_page.py, website/imprint_privacy.py: Adds per-page SEO meta tags and breadcrumb JSON-LD
  • website/static/header.html: Removes static meta description in favor of dynamic per-page descriptions
  • nicegui/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 output
  • pyproject.toml: Adds website/tests to pytest testpaths to separate website tests from library tests

Review feedback addressed (from #5767)

# Issue Resolution
1 Too many concerns bundled Split into 4 PRs (#5809, #5810, #5811, this one)
2 lastmod always date.today() Omitted lastmod entirely per Google's guidance
3 <html lang> affects all users Split to separate PR #5811
4 ui.status_code() no validation Split to separate PR #5810 for dedicated API review
5 _page_exception_handler reset is workaround Split to separate PR #5809
6 Missing breadcrumb on main page Added for consistency
7 test_seo.py in library tests Moved to website/tests/
8 <noscript> fallback value Dropped — Googlebot executes JS on nicegui.io
9 No integration tests for rendered pages Deferred — Google Search Console serves as integration test
10 Titles not capped at 60 chars Verified all 123 pages fit (max 50 chars)

Open question

The sitemap in this PR is hardcoded to the nicegui.io website routes. Should NiceGUI instead auto-populate sitemap.xml based on @ui.page and ui.sub_page registrations (#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

  • I chose a meaningful title that completes the sentence: "If applied, this PR will..."
  • The implementation is complete.
  • If this PR addresses a security issue, it has been coordinated via the security advisory process.
  • Pytests have been added (or are not necessary).
  • Documentation has been added (or is not necessary).

🤖 PR opened by Claude Code on behalf of @evnchn

- 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>
@evnchn evnchn added the documentation Type/scope: Documentation, examples and website label Feb 19, 2026
@falkoschindler falkoschindler added the review Status: PR is open and needs review label Feb 19, 2026
@falkoschindler falkoschindler added this to the 3.10 milestone Feb 19, 2026
@evnchn
Copy link
Collaborator Author

evnchn commented Feb 19, 2026

To prevent accidentally merging this PR until the child SEO-facing PRs are merged, I am adding a blocked label.

@evnchn evnchn added blocked Status: Blocked by another issue or dependency and removed review Status: PR is open and needs review labels Feb 19, 2026
@evnchn
Copy link
Collaborator Author

evnchn commented Feb 22, 2026

image

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 https://nicegui.io/examples/{example_name} page as an SEO-facing measure at the very least. For some demos where the running cost is low, we may even consider to dynamically-run them just like the UI element demos.

@evnchn
Copy link
Collaborator Author

evnchn commented Feb 22, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Status: Blocked by another issue or dependency documentation Type/scope: Documentation, examples and website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants