Skip to content

Fix OpenGraph tags on all important pages#765

Open
shayesdevel wants to merge 3 commits into
themotte:frostfrom
shayesdevel:fix/130
Open

Fix OpenGraph tags on all important pages#765
shayesdevel wants to merge 3 commits into
themotte:frostfrom
shayesdevel:fix/130

Conversation

@shayesdevel
Copy link
Copy Markdown
Contributor

@shayesdevel shayesdevel commented Feb 26, 2026

Summary

Fixes #130 -- OpenGraph and Twitter Card meta tags were broken or missing across the site.

Problems fixed

  1. Relative image URLs: og:image and twitter:image used relative paths (e.g. /assets/images/...) which social media crawlers cannot resolve. Now prefixed with SITE_FULL.
  2. Wrong og:site_name: Used request.host (raw hostname) instead of SITE_TITLE (human-readable name).
  3. Duplicate og:site_name: default.html and settings.html had two og:site_name tags.
  4. Wrong og:type: Homepage, settings, and other non-article pages used og:type=article. Now uses website for general pages, article for posts, profile for user pages.
  5. Invalid og:author: Used on non-article pages. Removed where inappropriate, kept twitter:creator where it makes sense (post/comment authors, user profiles).
  6. Wrong twitter:url: Submission comment view used p.permalink instead of comment_info.permalink.
  7. Missing OG tags: Error pages, login/signup forms, and the submit page had no OG tags at all.

Templates changed

  • default.html -- Fixed base OG tags (type, site_name, image URLs, removed duplicates)
  • submission.html -- Fixed post and comment OG tags, removed og:author
  • userpage.html -- Added og:type=profile, fixed title/site_name/description
  • settings.html -- Fixed all OG/Twitter tags, removed duplicates
  • settings2.html -- Fixed OG/Twitter tags
  • errors/error.html -- Added OG and Twitter tags
  • login/authforms.html -- Added OG and Twitter tags
  • submit.html -- Added OG and Twitter tags

Tests added

  • test_opengraph.py: Verifies og:title, og:image, og:type, og:site_name, and Twitter tags on front page, post pages, login page, and user profiles.

Test plan

  • CI tests pass
  • Paste a link to the site in Discord/Slack/Twitter and verify the preview card renders correctly
  • Check post links show post title and thumbnail in social previews
  • Check user profile links show username and banner in social previews

Generated with Claude Code

shayesdevel and others added 2 commits February 27, 2026 11:31
- Make og:image URLs absolute by prepending SITE_FULL (social crawlers
  need full URLs, not relative /assets/ paths)
- Fix og:type: use "website" for general pages, "article" for posts,
  "profile" for user pages
- Fix og:site_name: use SITE_TITLE consistently instead of request.host
- Remove duplicate og:site_name tags in default.html, settings.html,
  settings2.html
- Fix og:url in settings.html (was missing scheme, just had hostname)
- Fix twitter:url for comment permalinks (was pointing to post instead
  of comment)
- Add OG + Twitter Card tags to error pages, submit page, and login
  forms which previously had none
- Remove non-standard og:author tags (use og:article:author instead)
- Make og:title on userpage include site name for better social previews

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds test_opengraph.py verifying:
- Front page has og:title, og:image, og:type=website, twitter tags
- og:site_name appears exactly once (no duplicates)
- og:author is not present on non-article pages
- Post pages have og:title, og:image, og:type=article
- Login page has OG tags
- User profile has og:type=profile

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…resent)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zorbathut
Copy link
Copy Markdown
Contributor

(pasting in claude review about the things I actually care about)


Bug: og:image on userpage is still potentially relative. u.banner_url (user.py:467-470) falls back to assetcache_path(...) when the user has no custom
banner, which returns a relative path like /assets/images/.../site_preview.webp. The PR fixes this exact problem in every other template by prepending
SITE_FULL, but missed it here. Should be content="{{SITE_FULL}}{{u.banner_url}}" — but that would double-prefix when bannerurl is already absolute. The real
fix is either making banner_url always return an absolute URL (like thumb_url does) or handling both cases in the template.

Same issue for twitter:image on userpage.


The tests are very shallow — they check for tag presence in HTML but don't validate values:

  • No test verifies that og:image URLs are actually absolute (the core bug being fixed)
  • No test verifies og:site_name content is SITE_TITLE rather than request.host

These tests will catch regressions where tags are accidentally deleted, but won't catch the bugs this PR is actually fixing (relative URLs, wrong values).
Consider parsing the meta tags and asserting on content values, at least for og:image (starts with http) and og:site_name.


(haven't actually verified this in detail, sorry if this turns out to be wrong)

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.

Fix up OpenGraph tags on all important pages.

2 participants