From b805d7bd5eb57d5b0c3c3ca4115eefa9a8ca677f Mon Sep 17 00:00:00 2001 From: teahubxyz Date: Fri, 16 Oct 2026 10:28:36 +0000 Subject: [PATCH] Link previews: absolute og:image card for site pages Gitea 28.0.0's head_opengraph.tmpl. Pages that aren't a repository or a profile now point og:image at the absolute /assets/img/og-card.png (WhatsApp needs an absolute URL), give its size and alt text, and ask for the large card with twitter:card summary_large_image. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XvDrpBDoAJjW8z1kaa3GAa --- .../custom/templates/base/head_opengraph.tmpl | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 gitea/custom/templates/base/head_opengraph.tmpl diff --git a/gitea/custom/templates/base/head_opengraph.tmpl b/gitea/custom/templates/base/head_opengraph.tmpl new file mode 100644 index 0000000..5f41880 --- /dev/null +++ b/gitea/custom/templates/base/head_opengraph.tmpl @@ -0,0 +1,51 @@ +{{- /* og:description - a one to two sentence description of your object, maybe it only needs at most 300 bytes */ -}} +{{if .PageIsUserProfile}} + + + + + {{if .ContextUser.Description}} + + {{end}} +{{else if .Repository}} + {{if .Issue}} + + + {{if .Issue.Content}} + + {{end}} + {{else if or .PageIsDiff .IsViewFile}} + + + {{if and .PageIsDiff .Commit}} + {{- $commitMessageBody := .Commit.MessageBody -}} + {{- if $commitMessageBody -}} + + {{- end -}} + {{end}} + {{else}} + + + {{if .Repository.Description}} + + {{end}} + {{end}} + + {{if (.Repository.AvatarLink ctx)}} + + {{else}} + + {{end}} +{{else}} + {{/* Teahub: the 1200x630 card at an absolute URL (WhatsApp needs one), its size, and the large-card layout. */}} + + + + + + + + + +{{end}} +