This is a Hugo theme component that automatically generates metadata complying to The Open Graph Protocol as well as Twitter Cards. This is NOT a standalone theme and must not be treated as such.
-
Add the hugo-social-metadata repository as a submodule to be able to get upstream changes later
git submodule add https://github.com/msfjarvis/hugo-social-metadata.git themes/hugo-social-metadata
-
Start off by configuring a few things in your
config.toml
(or equivalent file depending on whether you use YAML or JSON). These will be picked up by the theme component and used to provide metadata for the site.
[params]
description = "A description for your awesome website goes here"
keywords = "some, keywords, that, describe, your, content"
twitterUsername = "@your_twitter_username"
socialImage = "path/to/the/twitter/card/image"
- Include the
hugo-social-metadata
theme as the leftmost element of the theme list variable in your config file. Forconfig.toml
, it will look something like this:
theme = ["hugo-social-metadata", "hyde"]
- Include the
social_metadata.html
partial in yourhead.html
like so:{{ partial "social_metadata.html" . }}
.
You can customize some of the generated metadata on a per-page basis. Setting description
, socialImage
or tags
in the frontmatter will override the defaults loaded from the main config file.
+++
description = "A nice description for this blogpost"
socialImage = "path/to/an/image/that/describes/this/post/best"
tags = ["this", "blog", "rocks!"]
+++
Check out the LICENSE file in the root of this repository.