feat: add Open Graph and Twitter Card meta tags for social sharing
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
<meta name="description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
|
<meta name="description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
|
||||||
<title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end }}</title>
|
<title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end }}</title>
|
||||||
|
|
||||||
|
{{ partial "opengraph.html" . }}
|
||||||
|
|
||||||
<!-- Bootstrap 5.x CSS -->
|
<!-- Bootstrap 5.x CSS -->
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
{{/* Open Graph / Social Media Meta Tags */}}
|
||||||
|
|
||||||
|
{{/* Basic OG tags */}}
|
||||||
|
<meta property="og:title" content="{{ .Title }}">
|
||||||
|
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}">
|
||||||
|
<meta property="og:url" content="{{ .Permalink }}">
|
||||||
|
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
|
||||||
|
<meta property="og:site_name" content="{{ .Site.Title }}">
|
||||||
|
<meta property="og:locale" content="{{ .Language.Lang }}">
|
||||||
|
|
||||||
|
{{/* Article-specific tags */}}
|
||||||
|
{{ if .IsPage }}
|
||||||
|
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
|
||||||
|
{{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format "2006-01-02T15:04:05Z07:00" }}">{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{/* Image handling: only render if images defined in frontmatter */}}
|
||||||
|
{{ with .Params.images }}
|
||||||
|
{{ range first 1 . }}
|
||||||
|
{{ $img := . }}
|
||||||
|
{{ if not (hasPrefix $img "http") }}
|
||||||
|
{{ $img = printf "%s%s" $.Permalink $img }}
|
||||||
|
{{ end }}
|
||||||
|
<meta property="og:image" content="{{ $img }}">
|
||||||
|
<meta name="twitter:image" content="{{ $img }}">
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{/* Twitter Card */}}
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="{{ .Title }}">
|
||||||
|
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}">
|
||||||
Reference in New Issue
Block a user