Adds social media meta tags and new param for featured images

This commit is contained in:
Josh Johnson 2024-02-19 22:19:19 -05:00
parent 830ad5392b
commit cde5d340bd
3 changed files with 21 additions and 3 deletions

View file

@ -129,6 +129,14 @@ These posts are rendered slightly different with an → to signify that it is re
![External URL](https://github.com/jnjosh/internet-weblog/raw/master/images/linkpost.png) ![External URL](https://github.com/jnjosh/internet-weblog/raw/master/images/linkpost.png)
#### Specifying a featured image for social media
Sometimes you want to feature an image as your featured image that will display when linking your post in social media. This can be done by including the `feature` parameter on your individual post. Note you don't need to put the URL, just the path to the image without a leading `/`
```
feature: "assets/posts/20240219/image.jpg"
```
### Variables ### Variables
| Variable | What value? | Required | | Variable | What value? | Required |

View file

@ -6,17 +6,27 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="{{ with .Site.Author.firstname }}{{ . }}{{ end }} {{ with .Site.Author.lastname }}{{ . }}{{ end }}"> <meta name="author" content="{{ with .Site.Author.firstname }}{{ . }}{{ end }} {{ with .Site.Author.lastname }}{{ . }}{{ end }}">
<meta name="description" content="{{ with .Site.Params.description }}{{ . }}{{ end }}"> <meta name="description" content="{{ with .Site.Params.description }}{{ . }}{{ end }}">
{{ hugo.Generator }}
{{ $siteTitle := .Site.Title }} {{ $title := $siteTitle }}{{ if .IsPage }}{{ $title = .Title }}
<meta property="og:type" content="article" />
<meta property="og:title" content="{{ $title }}">
{{ if .Param "feature" }}<meta property="og:image" content="{{ .Site.BaseURL }}{{ .Params.feature }}">{{ end }}
<meta property="og:url" content="{{ .Page.Permalink }}">
<meta property="og:description" content="{{ .Summary }}">
<meta property="og:site_name" content="@{{ .Site.Author.handle }}s {{ .Site.Title }}">
<meta name="twitter:card" content="summary_large_image">
{{ end }}
{{ hugo.Generator }}
{{ $.Scratch.Add "title" .Site.Title }} {{ $.Scratch.Add "title" .Site.Title }}
<title>{{ with .Title }}{{ if ne . ($.Scratch.Get "title") }}{{ . }} &middot; {{ end }}{{ end }}@{{ .Site.Author.handle }}s {{ .Site.Title }}</title> <title>{{ with .Title }}{{ if ne . ($.Scratch.Get "title") }}{{ . }} &middot; {{ end }}{{ end }}@{{ .Site.Author.handle }}s {{ .Site.Title }}</title>
<link rel="stylesheet" href="{{.Site.BaseURL}}css/weblog.css" media="screen" charset="utf-8" /> <link rel="stylesheet" href="{{.Site.BaseURL}}css/weblog.css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.2.14/css/lightgallery.min.css" type="text/css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.2.14/css/lightgallery.min.css" type="text/css" />
{{ partial "custom_stylesheets.html" . }} {{ partial "custom_stylesheets.html" . }}
{{ if .Site.Params.rssenabled }} {{ if .Site.Params.rssenabled }}
<link href="{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}" rel="alternate" type="application/rss+xml" title="{{.Site.Title}}" /> <link href="{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}" rel="alternate" type="application/rss+xml" title="{{.Site.Title}}" />
{{ end }} {{ end }}
</head> </head>
<body class="site"> <body class="site">

View file

@ -17,7 +17,7 @@ iweblog.application = function() {
cnt++; cnt++;
}); });
$('#photos').html(htmlString); $('#photos').html(htmlString);
$('#photos').lightGallery(); $('#photos').lightGallery();
} }