rottentheme/layouts/partials/head.html
Kumi 381922076f
fix: ensure default image for og and twitter cards
Updated the HTML partial to use a default image when `.Params.image` is undefined, improving robustness of Open Graph and Twitter card metadata. This ensures consistent presentation of content across social media, preventing missing image issues when a custom image is not provided.
2024-11-09 16:02:35 +01:00

28 lines
1 KiB
HTML

<head>
<meta charset="UTF-8">
<title>{{ .Title }}</title>
<meta name="description" content="{{ .Description }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{ hugo.Generator }}
{{ $style := resources.Get "css/style.css" }}
{{ $css := $style | minify | fingerprint }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}">
{{ $image := "" }}
{{ if .Params.image }}
{{ $image = .Params.image }}
{{ else }}
{{ $image = resources.Get "images/profile.jpg" }}
{{ end }}
<meta property="og:title" content="{{ .Title }}">
<meta property="og:description" content="{{ .Description }}">
<meta property="og:type" content="article">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:image" content="{{ .Site.BaseURL }}{{ $image }}">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{{ .Title }}">
<meta name="twitter:description" content="{{ .Description }}">
<meta name="twitter:image" content="{{ .Site.BaseURL }}{{ $image }}">
</head>