Add Open Graph and Twitter Card meta tags to all public pages

- templates/public/head.php: add centralised OG/Twitter tag rendering via $ogTags array;
  supports type, title, description, url, image, image_alt, site_name, article_author,
  article_published_time; twitter:card switches between summary_large_image / summary
  based on presence of og:image

- public/tfe.php: populate full article OG tags — og:type=article, canonical URL,
  og:image resolved from banner_path → first image file in thesis_files → omitted,
  og:image:alt, article:author, article:published_time (year-01-01); twitter:card
  summary_large_image when image present

- public/index.php, search.php, apropos.php, licence.php: add basic og:type=website
  tags (title, description, canonical url, site_name)

Sharing a thesis link on Slack, WhatsApp, iMessage, or any social platform will now
render a rich preview card with the thesis title, synopsis excerpt, and cover/banner image.
This commit is contained in:
Pontoporeia
2026-03-29 15:43:21 +02:00
parent 1dee1ea73f
commit 3a8ffa6afe
7 changed files with 105 additions and 3 deletions

View File

@@ -539,9 +539,11 @@ Goal: rename the tables and column to the canonical M2M pattern (`tags`, `thesis
site blurb for `index.php`, synopsis excerpt for `tfe.php`, page content intro for
`apropos.php`/`licence.php`. Necessary for search indexing and link preview cards.
- [ ] **No Open Graph tags** - `tfe.php` is the ideal candidate for `og:title`, `og:description`
(synopsis), `og:image` (banner or cover path through `/media.php`), `og:type=article`.
Without them, sharing a thesis link on social media or messaging apps shows a blank preview.
- [x] **No Open Graph tags** - `tfe.php` now emits `og:type=article`, `og:title`, `og:description`,
`og:url`, `og:image` (banner → first image file → none), `og:image:alt`, `og:site_name`,
`article:author`, `article:published_time`, plus `twitter:card`/`twitter:title`/`twitter:description`/
`twitter:image`. All other public pages (`index`, `search`, `apropos`, `licence`) emit basic
`og:type=website` tags. OG rendering is centralised in `templates/public/head.php` via `$ogTags` array.
### H - Minor / low-hanging fruit