Contains hugo partials to add SEO to your project
Partials available
- Adsense
- Favicon
- Google analytics
- Google tag manager
- Meta tags
- Opengraph
- Twitter tags
- In the root of your hugo repo, run
npm i @tanglemedia/hugo-seo
- In your site config file
config.{toml,yaml,json}
, add the following:
"module": {
"mounts": [
"source": "node_modules/@tanglemedia/hugo-seo/layouts",
"target": "layouts"
]
}
# Goes to the head tag.
{{ partial "meta/adsense/adsense-head" (dict "enable" true "code" "ca-pub-1234567890123456") }}
# Placement of the ad. This goes in the body tag.
{{ partial "meta/adsense/adsense-body" (dict
"enable" true
"code" "ca-pub-1234567890123456"
"slot" "1234567890"
"format" "auto"
)
}}
To generate favicons, you can use the following favicon generators:
Put all the generated assets to the static folder.
{{ partial "meta/favicon" (dict
"color" "#000000"
"favicon" "static/favicon.ico"
"favicon_180x180" "static/favicon-180x180.png"
"favicon_32x32" "static/favicon-32x32.png"
"favicon_16x16" "static/favicon-16x16.png"
"safariPinnedTabIcon" "static/safari-pinned-tab.svg"
"siteManifestPath" "static/site.webmanifest"
)
}}
{{ partial "meta/google-analytics" (dict "code" "G-1234567") }}
{{ partial "meta/google-tag-manager" (dict "code" "GTM-1234567" "noscript" false) }}
{{ partial "meta/opengraph" (dict
"ctx" .
"title" "Test"
"description" "Test"
"type" "homepage"
"url" "https://example.com"
"image" "https://example.com/image.jpg"
"audio" "https://example.com/audio.mp3"
"locale" "en_US"
"video" "https://example.com"
"relatedPages" .Site.RegularPages
)
}}
{{ partial "meta/meta-tags" (dict
"title" "Sample Page"
"description" "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
"author" "XXX Company"
"keywords" (slice "keyword1" "keyword2" "keyword3")
)
}}
{{ partial "meta/twitter-tags" (dict
"title" "Sample Page"
"image" "https://example.com/image.jpg"
"description" "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
)
}}