Skip to content

Commit d6da071

Browse files
SableRafclaude
andcommitted
Fix OG image URL by serving from a stable public/ path
The content-hashed _astro/ path becomes stale whenever the image changes, breaking cached social crawls. Serve from public/og-image.png for a predictable URL, and add 301 redirects to recover any stale cached paths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 05943ad commit d6da071

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

netlify.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@
44
publish = "dist"
55

66
[build.environment]
7-
DEPLOY_TARGET = "netlify"
7+
DEPLOY_TARGET = "netlify"
8+
9+
[[redirects]]
10+
from = "/_astro/og-image*"
11+
to = "/og-image.png"
12+
status = 301
13+
14+
[[redirects]]
15+
from = "/_astro/PCD2026_og-image_tinyfied*"
16+
to = "/og-image.png"
17+
status = 301

pcd-website/public/og-image.png

235 KB
Loading

pcd-website/src/pages/event/[id].astro

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { loadNodes, canonicalEventId } from '../../lib/nodes';
33
import type { Node } from '../../lib/nodes';
44
import MapView from '../../components/MapView.vue';
55
import '../../styles/global.css';
6-
import { getImage } from 'astro:assets';
7-
import ogImageSrc from '../../images/PCD2026_og-image_tinyfied.png';
86
97
export async function getStaticPaths() {
108
const nodes = await loadNodes();
@@ -31,9 +29,7 @@ const canonicalId = canonicalEventId(node);
3129
const canonicalUrl = `${siteUrl}${base}/event/${canonicalId}/`;
3230
const redirectUrl = redirectTo ? `${base}/event/${redirectTo}/` : null;
3331
34-
const ogImageUrl = redirectUrl
35-
? ''
36-
: `${siteUrl}${(await getImage({ src: ogImageSrc, format: 'jpeg', quality: 85 })).src}`;
32+
const ogImageUrl = redirectUrl ? '' : `${siteUrl}${base}/og-image.png`;
3733
const title = `${node.event_name} — Processing Community Day 2026`;
3834
const locationLabel = node.city || 'your city';
3935
const description = node.event_short_description || node.details_text.slice(0, 200).trimEnd() || `Join the global celebration at Processing Community Day 2026 in ${locationLabel}. Find your local event on the map, or start a PCD in your community.`;

pcd-website/src/pages/index.astro

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ import ogImageSrc from '../images/PCD2026_og-image_tinyfied.png';
88
const nodes = await loadNodes();
99
1010
const siteUrl = Astro.site ? Astro.site.href.replace(/\/$/, '') : '';
11-
const [ogImage, bannerImage] = await Promise.all([
12-
getImage({ src: ogImageSrc, format: 'jpeg', quality: 85 }),
13-
getImage({ src: ogImageSrc, format: 'webp', quality: 80, width: 960 }),
14-
]);
15-
const ogImageUrl = `${siteUrl}${ogImage.src}`;
11+
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
12+
const bannerImage = await getImage({ src: ogImageSrc, format: 'webp', quality: 80, width: 960 });
13+
const ogImageUrl = `${siteUrl}${base}/og-image.png`;
1614
const pageUrl = Astro.url.href;
1715
---
1816

0 commit comments

Comments
 (0)