add optional ogp and twitter meta tags

This commit is contained in:
Simon Li
2020-06-18 20:47:20 +01:00
parent 62014e5135
commit 9225ccd9ab
5 changed files with 26 additions and 0 deletions

View File

@@ -134,6 +134,11 @@ description: "This is the subtext above the main heading in small letters"
#### Overriding CSS
To override CSS, you should create file `project_root/assets/css/override.css` and place all your CSS inside it. This file will be merged with standard CSS when the site is generated.
### Custom Meta Tags
You can add optional Open Graph and Twitter meta tags by adding `project_root/layouts/partials/ogp.html` and `project_root/layouts/partials/twitter.html`.
Refer to [/exampleSite/layouts/partials](/exampleSite/layouts/partials) for sample meta configs.
## Helpful Links
[Aether Blog Post](https://www.joehutch.com/post/aether-theme/) - See aether in action and learn more about the theme

View File

@@ -9,3 +9,5 @@ theme = "aether"
brand = "aether"
description = "aether Hugo theme for blogs"
bgimg = "img/ignasi_pattern_s.png"
metaCreator = "Joe Hutchinson"
metaImage = "img/ogimage.jpg"

View File

@@ -0,0 +1,7 @@
<meta property="og:locale" content="{{ .Site.Language.Lang }}">
<meta property="og:type" content="{{ if .IsHome }}website{{ else }}article{{ end }}">
<meta property="og:title" content="{{ .Site.Params.Brand }}">
<meta property="og:description" content="{{ .Site.Params.description }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:site_name" content="{{ .Site.Params.Brand }}">
<meta property="og:image" content="{{ .Site.Params.metaImage | absURL }}">

View File

@@ -0,0 +1,6 @@
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="{{ .Site.Params.Brand }}">
<meta name="twitter:description" content="{{ .Site.Params.description }}">
<meta name="twitter:site" content="{{ .Site.BaseURL }}">
<meta name="twitter:creator" content="{{ .Site.Params.metaCreator }}">
<meta name="twitter:image" content="{{ .Site.Params.metaImage | absURL }}">

View File

@@ -19,6 +19,12 @@
{{ if (fileExists "static/safari-pinned-tab.svg") -}}
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
{{ end -}}
{{ if (fileExists "layouts/partials/twitter.html") -}}
{{ partial "twitter.html" . }}
{{ end -}}
{{ if (fileExists "layouts/partials/ogp.html") -}}
{{ partial "ogp.html" . }}
{{ end -}}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
{{ $mainStyle := resources.Get "css/style.css" }}