Fix OpenGraph tags on all important pages#765
Conversation
- 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>
|
(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 Same issue for twitter:image on userpage. The tests are very shallow — they check for tag presence in HTML but don't validate values:
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). (haven't actually verified this in detail, sorry if this turns out to be wrong) |
Summary
Fixes #130 -- OpenGraph and Twitter Card meta tags were broken or missing across the site.
Problems fixed
og:imageandtwitter:imageused relative paths (e.g./assets/images/...) which social media crawlers cannot resolve. Now prefixed withSITE_FULL.og:site_name: Usedrequest.host(raw hostname) instead ofSITE_TITLE(human-readable name).og:site_name:default.htmlandsettings.htmlhad twoog:site_nametags.og:type: Homepage, settings, and other non-article pages usedog:type=article. Now useswebsitefor general pages,articlefor posts,profilefor user pages.og:author: Used on non-article pages. Removed where inappropriate, kepttwitter:creatorwhere it makes sense (post/comment authors, user profiles).twitter:url: Submission comment view usedp.permalinkinstead ofcomment_info.permalink.Templates changed
default.html-- Fixed base OG tags (type, site_name, image URLs, removed duplicates)submission.html-- Fixed post and comment OG tags, removedog:authoruserpage.html-- Addedog:type=profile, fixed title/site_name/descriptionsettings.html-- Fixed all OG/Twitter tags, removed duplicatessettings2.html-- Fixed OG/Twitter tagserrors/error.html-- Added OG and Twitter tagslogin/authforms.html-- Added OG and Twitter tagssubmit.html-- Added OG and Twitter tagsTests 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
Generated with Claude Code