diff options
author | Joe Hutchinson <hutch7995@gmail.com> | 2020-07-14 01:38:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 01:38:37 +0300 |
commit | 436ce6771cf339235e37504e629a756a7d199af8 (patch) | |
tree | d7872c8c2c0dfeef222fa4f53a9f157a54574934 | |
parent | 4514a6f9246a91da57fa63143ed3934b07d8ef6a (diff) | |
parent | 9225ccd9aba2396d0b10d9e11718abb42dd2f294 (diff) |
Merge pull request #56 from siutsin/meta-tags
add optional ogp and twitter meta tags
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | exampleSite/config.toml | 2 | ||||
-rw-r--r-- | exampleSite/layouts/partials/ogp.html | 7 | ||||
-rw-r--r-- | exampleSite/layouts/partials/twitter.html | 6 | ||||
-rw-r--r-- | layouts/partials/head.html | 6 |
5 files changed, 26 insertions, 0 deletions
@@ -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/posts/aether-theme/) - See aether in action and learn more about the theme
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 39af3b1..0c1f278 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -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" diff --git a/exampleSite/layouts/partials/ogp.html b/exampleSite/layouts/partials/ogp.html new file mode 100644 index 0000000..d2164e8 --- /dev/null +++ b/exampleSite/layouts/partials/ogp.html @@ -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 }}"> diff --git a/exampleSite/layouts/partials/twitter.html b/exampleSite/layouts/partials/twitter.html new file mode 100644 index 0000000..fc52000 --- /dev/null +++ b/exampleSite/layouts/partials/twitter.html @@ -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 }}"> diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 79eb808..0d319f7 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -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" }} |