Skip to content

docs: link previews, logo and favicon on the docs site - #2075

Open
amarkanday wants to merge 1 commit into
mainfrom
docs/seo-link-previews
Open

amarkanday wants to merge 1 commit into
mainfrom
docs/seo-link-previews

Conversation

@amarkanday

Copy link
Copy Markdown
Contributor

Part of #2038

What and why

A link to a docs page shows no preview card, and the theme has no logo or favicon. This adds:

  • docs/overrides/main.html, set as theme.custom_dir, with overrides/ in exclude_docs so it is not published. It emits og:site_name, og:type, og:title, og:description, og:url, og:image (with width and height), twitter:card (summary_large_image), twitter:title, twitter:description and twitter:image, from each page's title and description, falling back to the site's values. Titles are escaped once, so Power Analysis & Sample Size renders as &. Everything that reads page sits inside {% if page %}: page is None while MkDocs renders 404.html, and without the guard the strict build fails there.
  • theme.logo is controlvar-mark-small.svg (the heavier-outline variant meant for small sizes), and theme.favicon is favicon.svg, with favicon-32.png linked as a PNG fallback. og:image is controlvar-social-1280x640.png, the file's real size. All four are the Controlvar logo concept B, copied to docs/assets/brand/.
  • Licence: the logo files are covered by the repository's Apache-2.0 through REUSE.toml, as the maintainer decided. Apache-2.0 grants no rights to the project's name or marks (section 6).

This is the second of two docs-only pull requests for #2038. The first, #2061 (merged), added robots.txt and the per-page descriptions these tags read.

Verification

  • mkdocs build --strict exits 0 (same toolchain as scripts/docs_toolchain.sh). The two branches also build together (a throwaway merge, exit 0).
  • In site/: the home page, Quick Start and Power Analysis each carry one of every og/twitter tag (og:title count 1); og:image is https://docs.controlvar.com/assets/brand/controlvar-social-1280x640.png, present in site/assets/brand/ and 1280 x 640 by file; site/404.html is built and has no og tags; site/overrides/ does not exist.
  • Plant: removing the two {% if page %} / {% endif %} lines makes mkdocs build --strict exit 1 with jinja2.exceptions.UndefinedError: 'None' has no attribute 'meta'; restored, it exits 0.
  • python scripts/doc_claims.py check: problems: 0.
  • backend/tests/unit/infrastructure/test_docs_only_gate.py: 47 passed; scripts/classify_changes.py on this diff prints docs_only=true.
  • scripts/check_dco.py origin/main HEAD: ok.

NOT VERIFIED

  • How Slack, X, LinkedIn or a search engine render the card; no crawler or preview tool was run.
  • That the logo looks right in the header at every width (the build was not opened in a browser).
  • The deployed site: it builds on a tag, and the Doc Examples (render) check is the only pull-request build of it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NpxPyav9uBxNuiXsDvD8qn

A link to a docs page showed no preview card, and the theme had no logo or
favicon.

- docs/overrides/main.html (theme.custom_dir; overrides/ is in exclude_docs
  so it is not published) emits og:* and twitter:* tags from each page's
  title and description, falling back to the site's values. og:image is the
  absolute URL of the 1280x640 social card, with its size declared. Everything
  that reads `page` is inside `{% if page %}`: page is None for 404.html, and
  without the guard the strict build fails there.
- theme.logo is the small mark (heavier outline, for small sizes);
  theme.favicon is favicon.svg, with favicon-32.png linked as a fallback.
  The files are the Controlvar logo concept B, copied to docs/assets/brand/.

Part of #2038

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011kqtSDC7sd5ue3m6LuwdXV
Signed-off-by: amarkanday <a.markanday@gmail.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant