From 0971422110920f48f6f4bb6207ef878eccfa4177 Mon Sep 17 00:00:00 2001 From: Igor Baiborodine Date: Wed, 21 Dec 2022 08:37:35 -0500 Subject: [PATCH] Issue-459: Fix Open Graph metadata (#463) * Include Hugo's _internals/opengraph.html * Add documentation section for Open Graph metadata * chore(docs): update TOC Co-authored-by: igor-baiborodine --- README.md | 28 +++++++++++++++++++++++++++- exampleSite/config.toml | 24 ++++++++++++------------ layouts/_default/baseof.html | 11 ++--------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 936b040db..ad2279303 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Please use the following guidelines if you want to start a discussion: - [Manual Summary Split](#manual-summary-split) - [Front Matter Summary Split](#front-matter-summary-split) - [No Summary Split](#no-summary-split) + - [Open Graph Metadata](#open-graph-metadata) - [Table of Contents (TOC)](#table-of-contents-toc) - [Series Taxonomy](#series-taxonomy) - [External Images](#external-images) @@ -373,6 +374,31 @@ This summary will also be followed by the _Continue reading_ link. If you want to display the entire article without the _Continue Reading_ link, set the `noSummary` variable to `true` in your content file. +### Open Graph Metadata + +The following base Open Graph metadata is included by default in all pages: `og:site_name`, `og:title` +, `og:description`, `og:type`, `og:url`, `article:section`, `article:published_time`, and `article:modified_time` where +the `article:published_time` and `article:modified_time` tags will have the same timestamp value as the `date` front +matter variable. + +Additional metadata can be included by adding the following front matter variables: +- `publishDate` for `article:published_time` +- `lastmod` for `article:modified_time` +- `images` for `og:image` +- `audio` for `og:audio` +- `videos` and `og:video` + +For example: +```markdown +title: "Open Graph Metadata with Extra Front Matter Variables" +date: 2022-12-19T19:00:00-05:00 +publishDate: 2022-12-19T20:00:00-05:00 +lastmod: 2022-12-19T21:00:00-05:00 +images: ["/img/content/article/open-graph-metadata-with-extra-front-matter-variables/thumbnail.jpg"] +audio: "/audio/icq-remix.mp3" +videos: ["/video/test_mp4_video.mp4"] +``` + ### Table of Contents (TOC) To enable the automatic creation of a table of contents (TOC), set the `toc` front matter variable to `true` in your @@ -394,7 +420,7 @@ and use the `toc` shortcode like this: ### Series Taxonomy In case you want to group some articles as a series, you have to add the `series` front matter variable to each article -and set its value to the name of the series, for example, `series: "My New Super Series"`. +and set its value to the name of the series, for example, `series: ["My New Super Series"]`. The page at `/series/` will list all the series. To list all articles for a particular series within markdown, you can use the `series` shortcode with the series name in question, for instance: diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 51e51ac22..e9eb6c677 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -171,25 +171,25 @@ disqusShortname = "" title = "Mein cooler neuer Blog" subtitle = "Hallo Welt! Dies ist der epischste Untertitel aller Zeiten." -# don't change anything below -[taxonomies] - author = "author" - tag = "tags" - category = "categories" - series = "series" - -[outputs] - home = [ "HTML", "JSON", "RSS" ] - page = [ "HTML" ] - [markup] defaultMarkdownHandler = 'goldmark' [markup.goldmark] [markup.goldmark.renderer] - # Change to 'true' if you need to render raw HTML within your markdown content + # change to 'true' if you need to render raw HTML within your markdown content unsafe = false [markup.tableOfContents] endLevel = 5 ordered = false startLevel = 2 + +# do NOT change anything below +[taxonomies] + author = "author" + tag = "tags" + category = "categories" + series = "series" + +[outputs] + home = [ "HTML", "JSON", "RSS" ] + page = [ "HTML" ] diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index dcca86671..4c6422496 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -68,16 +68,9 @@ - - - - - {{- if .IsPage }} - - {{- else -}} - - {{- end }} + + {{ template "_internal/opengraph.html" . }} {{ partial "favicon.html" . }}