Changeset 61514f2 in Klonkt


Ignore:
Timestamp:
06/30/2026 01:01:58 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
d5aa7c8
Parents:
4d63c36
Message:

fix(seo): make og:image / twitter:image / JSON-LD image absolute

A post cover arrives as a relative /media/... path. Mastodon resolves it against the page URL,
but the OGP spec wants an absolute URL and stricter scrapers (WhatsApp, Signal, some fediverse
clients) won't resolve a relative one → no preview image. Absolutize _socialImage against the
canonical origin so every link/preview gets the real cover. (The AP Note image was already
absolute.)

  • src/views/shell.ejs — absolutize _socialImage when it's a root-relative path

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/shell.ejs

    r4d63c36 r61514f2  
    7373  _socialImage = ogOrigin + '/og/' + encodeURIComponent(safeSite.slug) + '.png';
    7474  _ogGenerated = true;
     75}
     76// og:image / twitter:image / JSON-LD image MUST be absolute (OGP spec). A post cover arrives as
     77// a relative /media/... path; strict scrapers (WhatsApp/Signal/some fediverse clients) won't
     78// resolve it against the page URL → no preview image. Absolutize against the canonical origin.
     79if (_socialImage && _socialImage.charAt(0) === '/' && _socialImage.charAt(1) !== '/' && typeof ogOrigin !== 'undefined' && ogOrigin) {
     80  _socialImage = ogOrigin + _socialImage;
    7581}
    7682const _ogType = isPostPage ? 'article' : 'website';
Note: See TracChangeset for help on using the changeset viewer.