Skip to content

Add Open Graph and Twitter card previews - #153

Open
alies-dev wants to merge 2 commits into
psalm:masterfrom
alies-dev:og-previews
Open

alies-dev wants to merge 2 commits into
psalm:masterfrom
alies-dev:og-previews

Conversation

@alies-dev

Copy link
Copy Markdown
Contributor
  • Shared links to psalm.dev only got og:site_name and an old screenshot as og:image, so Slack, Discord, X and others showed a bare title or a cropped image
  • includes/meta.php now emits the full Open Graph and Twitter card set (type, title, description, url, image with size, type and alt text, summary_large_image, @psalmphp) plus theme-color; views override the defaults through $og
  • New 1200x630 images in assets/og/ for the homepage, /play, and snippet pages (/r/<hash>). The snippet image and copy are the same for every snippet for now
  • Pages without their own copy (support, plugins, blog index) keep the homepage image, and their title and description fall back to <title> and the meta description
  • Articles keep their small thumbnail card, with their tags moved into $og so nothing is emitted twice
  • The images use the site's own webfonts (National 2, Tiempos Text), rasterized, and JetBrains Mono for code
  • psalm_preview.png is no longer referenced, so it is removed

Static 1200x630 PNGs in the site's style, used as og:image.
includes/meta.php now emits og:type, og:title, og:description, og:url, og:image with its type, size and alt text, twitter:card, twitter:site and theme-color. Views override the defaults through $og: the playground and snippet pages get their own image and copy, and articles move their existing tags over to it. The old psalm_preview.png is no longer used.
@alies-dev alies-dev self-assigned this Nov 8, 2026
Comment thread views/article.php
$meta_description = $description;
$timestamp = strtotime($article->date);
$published = $timestamp === false ? null : date('c', $timestamp);
$og = [
Comment thread views/article.php
$published = $timestamp === false ? null : date('c', $timestamp);
$og = [
'type' => 'article',
'title' => $article->title,
Comment thread views/index.php
// /play (?page=play from .htaccess): nav plus the playground filling the viewport, nothing else
$playground_page = ($_GET['page'] ?? null) === 'play';
$canonical_url = $playground_page ? 'https://psalm.dev/play' : 'https://psalm.dev/';
$og = $playground_page ? [
Comment thread views/snippet.php
header('X-Robots-Tag: noindex, follow');
$canonical_url = false;
// Same preview for every snippet: it never shows the submitted code
$og = [
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.

2 participants