@tanglemedia/hugo-seo

0.0.1 • Public • Published

Hugo SEO

Contains hugo partials to add SEO to your project

Partials available

  • Adsense
  • Favicon
  • Google analytics
  • Google tag manager
  • Meta tags
  • Opengraph
  • Twitter tags

How to install

  • 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"
    ]
}

Adsense

# 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"
    )
}}

Favicon

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"
    )
}}

Google Analytics

{{ partial "meta/google-analytics" (dict "code" "G-1234567") }}

Google Tag Manager

{{ partial "meta/google-tag-manager" (dict "code" "GTM-1234567" "noscript" false) }}

Opengraph

{{ 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
    ) 
}}

Meta Tags

{{ 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")
    ) 
}}

Twitter Tags

{{ partial "meta/twitter-tags" (dict
        "title" "Sample Page"
        "image" "https://example.com/image.jpg"
        "description" "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
    ) 
}}

Package Sidebar

Install

npm i @tanglemedia/hugo-seo

Weekly Downloads

147

Version

0.0.1

License

MIT

Unpacked Size

10.3 kB

Total Files

11

Last publish

Collaborators

  • tanglemedia-dev