vienalatina/themes/vienalatina/layouts/partials/seo-head.html
Claude 790bd2230f
Share buttons, and a card that arrives with its picture
Seven buttons under the title of every post and again after the text —
the reader who decides on sight and the one who decides at the end are
different people.

Four are ordinary links and work with scripting off: WhatsApp, Facebook,
Bluesky and Mastodon all take a URL that opens their own composer. The
other three cannot be, and the reason is worth writing down rather than
rediscovering: Signal has no web intent at all — it is a share target in
the operating system's sheet and nowhere else — and Instagram accepts no
link from anybody, by design, which is why every site with an Instagram
share button is really offering a copied link. Both call
navigator.share() where it exists and copy the address where it does
not, beside a plain «Copiar enlace» that always works.

Mastodon has no central address: the composer lives on whichever server
the reader has an account on. It asks once, keeps the answer, and
without scripting falls back to the association's own server.

The icons are simplified marks in one visual language rather than the
official logo files — reproducing those from memory gives something
subtly wrong, and subtly wrong looks worse than plainly simple. Each
carries its name for a screen reader and in `title` for a cursor.

**And the half that was actually broken.** og:image pointed at the
original upload: a photograph off a phone, two to five megabytes.
WhatsApp fetches preview images on a tight budget and gives up on a file
that size, so the card arrived as a title and a link with a blank where
the picture should be. Hugo copies static/ and processes assets/, and
only the second can be resized — so config.yaml mounts static/uploads
and static/brand into assets/ as well, leaving every existing URL and
everything the editor commits untouched, and seo-head.html now builds
the card: 1200x630, filled from the middle, 93 KB measured against a
22 MB source. The logo fallback is fitted rather than filled and keeps
its own format, because a wordmark cropped to a landscape card loses its
ends and a transparent PNG turned into JPEG lands on a black square.

og:image:width and :height go out with it, from the generated file so
they cannot disagree with it. Several clients draw the small card rather
than the large one when they would have to fetch the image to find out
how big it is.

Three guards, each verified by reintroducing its own bug: a button that
needs the script says so in the markup; a hidden button is actually
hidden (`[hidden]` is a user-agent rule and `display: inline-flex` beat
it, so all seven showed and three did nothing); and every encoded link
is marked safeURL, without which Go's escaper encoded it a second time
and WhatsApp opened with %253A spelled out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
2026-10-09 08:47:42 +00:00

270 lines
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{/* GEO/SEO surfaces — ported from theme/inc/seo.php:
hreflang alternates, Open Graph + og:locale(:alternate), Twitter Card,
JSON-LD BlogPosting (articles) / Blog (home), all with inLanguage. */}}
{{ $localeMap := .Site.Params.localeMap }}
{{ $locale := index $localeMap .Language.Lang | default "es_ES" }}
{{ $desc := "" }}
{{ if .IsPage }}{{ $desc = .Description | default (.Summary | plainify | truncate 200) }}{{ else }}{{ $desc = partial "site-tagline.html" . }}{{ end }}
{{/* One line, always. A summary pulled out of the body arrives with the line
breaks the prose had, and a newline inside og:description is a card that
renders raggedly in some readers and truncated in others. */}}
{{ $desc = trim ($desc | plainify | replaceRE "\\s+" " ") " " }}
{{/* The picture a share card shows. A page's own image when it has one, and
otherwise the fallback: the logo uploaded in Gestión → Marca, or
`params.defaultImage` when there is no logo. The logo comes first because
it is the one somebody can change without the repository — and because
`defaultImage` only ever existed as the line to fill in once a logo
arrived. With neither, a card shows title and description and no picture,
which is what happened before either existed.
Absolute, because WhatsApp, Signal, Mastodon and Bluesky all fetch it from
outside and a relative path means nothing to them. */}}
{{ $brandLogo := "" }}{{ $chosen := "" }}
{{ with site.Data.brand }}{{ $brandLogo = .logo }}{{ end }}
{{ with site.Data.site }}{{ $chosen = .share_image }}{{ end }}
{{/* The picture chosen in Identidad wins over the logo, which wins over the
one in config.yaml: most sites want their logo and the field exists for the
ones that want something else. */}}
{{ $fallback := or $chosen (or $brandLogo .Site.Params.defaultImage) }}
{{/* The card is *generated*, not pointed at.
What used to go out was the original upload — a photograph off a phone,
two to five megabytes. WhatsApp fetches a preview image on a tight budget
and gives up on a file that size, so the card arrived as a title and a
link with a blank where the picture should be. That is the whole reason
`static/uploads` is mounted into `assets/` in config.yaml: Hugo copies
static files and processes asset files, and only one of those can be
resized.
A post's own photograph is filled to 1200×630 — the size every client
draws its large card at — and comes out at 80–150 KB. The fallback is
fitted rather than filled, because a wordmark cropped to a landscape card
is a wordmark with its ends cut off.
An image the pipeline cannot find — a path typed by hand, a file added
after the build — falls back to exactly what happened before: the absolute
URL, no dimensions. Nothing is worse than it was. */}}
{{ $source := or .Params.image $fallback }}
{{ $image := "" }}{{ $cardW := "" }}{{ $cardH := "" }}{{ $cardType := "" }}
{{ with $source }}
{{ $image = . | absURL }}
{{ with resources.Get (strings.TrimPrefix "/" .) }}
{{ $card := "" }}
{{ if $.Params.image }}
{{ $card = .Fill "1200x630 Center q82 jpg" }}
{{ else }}
{{/* Fitted, and in its own format: the fallback is usually the logo, and a
logo cropped to a landscape card loses its ends — while converting a
transparent PNG to JPEG puts it on a black square, because JPEG has no
alpha to put it on anything else. */}}
{{ $card = .Fit "1200x630" }}
{{ end }}
{{ $image = $card.Permalink }}
{{ $cardW = $card.Width }}{{ $cardH = $card.Height }}{{ $cardType = $card.MediaType.Type }}
{{ end }}
{{ end }}
{{ $cardAlt := cond (ne .Params.image_alt nil) .Params.image_alt .Title }}
{{ $card := dict "url" $image "alt" $cardAlt "width" $cardW "height" $cardH "type" $cardType }}
<meta name="description" content="{{ $desc }}">
{{/* hreflang — one alternate per language sibling + x-default to Spanish */}}
{{ if .IsTranslated }}
{{ range .AllTranslations }}
<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}">
{{ end }}
{{ range .AllTranslations }}{{ if eq .Language.Lang "es" }}
<link rel="alternate" hreflang="x-default" href="{{ .Permalink }}">
{{ end }}{{ end }}
{{ end }}
{{ if and .IsPage (eq .Section "post") }}
{{/* ---- Article ---- */}}
<meta property="og:type" content="article">
<meta property="og:site_name" content="{{ partial "site-name.html" . }}">
<meta property="og:title" content="{{ .Title }}">
<meta property="og:description" content="{{ $desc }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:locale" content="{{ $locale }}">
{{ range .Translations }}
{{ with index $localeMap .Language.Lang }}<meta property="og:locale:alternate" content="{{ . }}">{{ end }}
{{ end }}
{{ partial "og-image.html" $card }}
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" }}">
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" }}">
{{ with .Params.author }}<meta property="article:author" content="{{ . }}">{{ end }}
<meta name="twitter:card" content="{{ if $image }}summary_large_image{{ else }}summary{{ end }}">
<meta name="twitter:title" content="{{ .Title }}">
<meta name="twitter:description" content="{{ $desc }}">
{{ $schema := dict
"@context" "https://schema.org"
"@type" "BlogPosting"
"inLanguage" .Site.Language.LanguageCode
"headline" .Title
"description" $desc
"url" .Permalink
"datePublished" (.Date.Format "2006-01-02T15:04:05-07:00")
"dateModified" (.Lastmod.Format "2006-01-02T15:04:05-07:00")
"author" (dict "@type" "Person" "name" (.Params.author | default .Site.Title))
"publisher" (dict "@type" "Organization" "name" .Site.Title "url" .Site.Home.Permalink)
"mainEntityOfPage" (dict "@type" "WebPage" "@id" .Permalink)
}}
{{/* The author's own page, when they have published one. An answer engine
citing this article can then say who wrote it and point somewhere real —
which is the whole reason the byline carries a URL. */}}
{{ with .Params.author_url }}
{{ $schema = merge $schema (dict "author" (dict
"@type" "Person"
"name" ($.Params.author | default $.Site.Title)
"url" (. | absURL))) }}
{{ end }}
{{ with $image }}{{ $schema = merge $schema (dict "image" .) }}{{ end }}
<script type="application/ld+json">{{ $schema | jsonify (dict "indent" " ") | safeJS }}</script>
{{ partial "breadcrumbs-schema.html" . }}
{{ partial "faq-schema.html" . }}
{{/* An event is also an Event. This is what puts a date next to the result in a
search listing, and what an answer engine reads when somebody asks what is
on in Vienna this weekend — the article alone says none of it in a form a
machine can use. */}}
{{ with .Params.event_date }}
{{ $when := . | time.AsTime }}
{{ $start := $when.Format "2006-01-02" }}
{{ with $.Params.event_time }}{{ $start = printf "%sT%s:00" $start . }}{{ end }}
{{ $event := dict
"@context" "https://schema.org"
"@type" "Event"
"name" $.Title
"startDate" $start
"url" $.Permalink
"inLanguage" $.Site.Language.LanguageCode
"eventAttendanceMode" "https://schema.org/OfflineEventAttendanceMode"
"eventStatus" "https://schema.org/EventScheduled"
"organizer" (dict "@type" "Organization" "name" $.Site.Title "url" $.Site.Home.Permalink)
}}
{{ with $desc }}{{ $event = merge $event (dict "description" .) }}{{ end }}
{{ with $image }}{{ $event = merge $event (dict "image" .) }}{{ end }}
{{ with $.Params.event_location }}
{{ $event = merge $event (dict "location" (dict
"@type" "Place"
"name" .
"address" (dict "@type" "PostalAddress" "addressLocality" "Wien" "addressCountry" "AT"))) }}
{{ end }}
<script type="application/ld+json">{{ $event | jsonify (dict "indent" " ") | safeJS }}</script>
{{ end }}
{{ else if .IsHome }}
{{/* ---- Home ---- */}}
<meta property="og:type" content="website">
<meta property="og:site_name" content="{{ partial "site-name.html" . }}">
<meta property="og:title" content="{{ partial "site-name.html" . }}">
<meta property="og:description" content="{{ $desc }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:locale" content="{{ $locale }}">
{{/* The home page shared without a picture until there was one to use. Now
that an admin can upload a logo, the front page of the site is the last
place that should share as a bare link. */}}
{{ partial "og-image.html" (merge $card (dict "alt" (partial "site-name.html" .))) }}
{{/* The organisation, as a search or answer engine reads it. Everything
overridable lives in Gestión → Identidad; `areaServed` stays here because a
city is a fact about this association and not a setting. */}}
{{ $org := dict
"@context" "https://schema.org"
"@type" "Organization"
"name" (partial "site-name.html" .)
"url" .Site.Home.Permalink
"description" (partial "site-tagline.html" .)
"areaServed" (dict "@type" "City" "name" "Wien" "addressCountry" "AT")
}}
{{ with site.Data.site }}
{{/* sameAs is how an engine knows an Instagram account and this site are one
body — the single highest-value field here for being found at all. */}}
{{ with .sameAs }}{{ $org = merge $org (dict "sameAs" .) }}{{ end }}
{{ with .email }}
{{ $org = merge $org (dict "contactPoint" (dict
"@type" "ContactPoint" "contactType" "general" "email" .)) }}
{{ end }}
{{ if or .city .street }}
{{ $address := dict "@type" "PostalAddress" "addressCountry" "AT" }}
{{ with .city }}{{ $address = merge $address (dict "addressLocality" .) }}{{ end }}
{{ with .street }}{{ $address = merge $address (dict "streetAddress" .) }}{{ end }}
{{ with .phone }}{{ $org = merge $org (dict "telephone" .) }}{{ end }}
{{ $org = merge $org (dict "address" $address) }}
{{ end }}
{{ end }}
{{/* The same fallback as the share card: the admin's logo, then the configured
default. This is the field a search engine uses to put a mark beside the
organisation's name, so it should be the logo somebody actually uploaded. */}}
{{ with $fallback }}{{ $org = merge $org (dict "logo" (. | absURL)) }}{{ end }}
{{ with .Site.Params.sameAs }}{{ $org = merge $org (dict "sameAs" .) }}{{ end }}
<script type="application/ld+json">{{ $org | jsonify (dict "indent" " ") | safeJS }}</script>
{{ $posts := first 10 (where .Site.RegularPages "Section" "post") }}
{{ $blogPost := slice }}
{{ range $posts }}
{{ $entry := dict
"@type" "BlogPosting"
"headline" .Title
"url" .Permalink
"datePublished" (.Date.Format "2006-01-02T15:04:05-07:00")
"author" (dict "@type" "Person" "name" (.Params.author | default .Site.Title))
}}
{{ with .Description }}{{ $entry = merge $entry (dict "description" .) }}{{ end }}
{{ $blogPost = $blogPost | append $entry }}
{{ end }}
{{ $schema := dict
"@context" "https://schema.org"
"@type" "Blog"
"name" .Site.Title
"description" $desc
"url" .Permalink
"inLanguage" .Site.Language.LanguageCode
}}
{{ if $blogPost }}{{ $schema = merge $schema (dict "blogPost" $blogPost) }}{{ end }}
<script type="application/ld+json">{{ $schema | jsonify (dict "indent" " ") | safeJS }}</script>
{{ else if .IsPage }}
{{/* ---- A static page: Acerca de, Contacto, their subpages ----
This branch did not exist, so a page shared as a bare link — no title card,
no picture, nothing for an answer engine to read beyond the prose. It is a
document about the organisation rather than an article, hence WebPage
rather than BlogPosting, and no author: a page is the site speaking. */}}
<meta property="og:type" content="website">
<meta property="og:site_name" content="{{ partial "site-name.html" . }}">
<meta property="og:title" content="{{ .Title }}">
<meta property="og:description" content="{{ $desc }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:locale" content="{{ $locale }}">
{{ range .Translations }}
{{ with index $localeMap .Language.Lang }}<meta property="og:locale:alternate" content="{{ . }}">{{ end }}
{{ end }}
{{ partial "og-image.html" $card }}
<meta name="twitter:card" content="{{ if $image }}summary_large_image{{ else }}summary{{ end }}">
<meta name="twitter:title" content="{{ .Title }}">
<meta name="twitter:description" content="{{ $desc }}">
{{ $schema := dict
"@context" "https://schema.org"
"@type" "WebPage"
"inLanguage" .Site.Language.LanguageCode
"name" .Title
"description" $desc
"url" .Permalink
"dateModified" (.Lastmod.Format "2006-01-02T15:04:05-07:00")
"isPartOf" (dict "@type" "WebSite" "name" .Site.Title "url" .Site.Home.Permalink)
"publisher" (dict "@type" "Organization" "name" .Site.Title "url" .Site.Home.Permalink)
}}
{{ with $image }}{{ $schema = merge $schema (dict "image" .) }}{{ end }}
<script type="application/ld+json">{{ $schema | jsonify (dict "indent" " ") | safeJS }}</script>
{{ partial "breadcrumbs-schema.html" . }}
{{ partial "faq-schema.html" . }}
{{ end }}