diff --git a/content/posts/dynamic-opengraph-images-with-hugo/index.md b/content/posts/dynamic-opengraph-images-with-hugo/index.md index 58d2a17..b518971 100644 --- a/content/posts/dynamic-opengraph-images-with-hugo/index.md +++ b/content/posts/dynamic-opengraph-images-with-hugo/index.md @@ -132,25 +132,23 @@ This is a great starting point for what I want to accomplish, but I'm going to m ### My tweaks As I mentioned earlier, I want to have basically three recipes for baking my OG images: one for the homepage, one for standard posts, and one for posts with an associated thumbnail. They'll all use the same basic code, though, so I wanted to be sure that my setup didn't repeat itself too much. +I'll start with fetching my resources up front, and initializing a `$text` variable: + ```jinja-html -// torchlight! {"lineNumbers": true} {{ $img := resources.Get "og_base.png" }} {{ $font := resources.Get "/FiraMono-Regular.ttf" }} {{ $text := "" }} - - - - - +``` + +If it's the homepage, I'll set `$text` to hold the site description: + +```jinja-html {{- if .IsHome }} {{ $text = .Site.Params.Description }} {{- end }} +``` {{- if .IsPage }} -{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} - -{{ with .PublishDate }}{{ end }} -{{ with .Lastmod }}{{ end }} {{ $text = .Page.Title }} {{ end }}