Skip to content

Commit

Permalink
- Add SEO elements to header, i18l friendly (#122)
Browse files Browse the repository at this point in the history
- Add Hugo related SEO parameters to example config.toml
- Add relevant instructions to the README.md file
  • Loading branch information
dudil authored and pacollins committed Feb 27, 2018
1 parent 62b074f commit 020882f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Expand Up @@ -19,6 +19,7 @@ interested in seeing a live example.
- [exampleSite](#examplesite)
- [config.toml](#configtoml)
- [Hugo's Built-In Server](#hugos-built-in-server)
- [Hugo's website SEO](#hugos-website-seo)
- [Shortcodes](#shortcodes)
- [fancybox](#fancybox)
- [img-post](#img-post)
Expand Down Expand Up @@ -115,6 +116,37 @@ hugo server

You will then be able to view your live website at [localhost:1313](http://localhost:1313).

### Hugo's website SEO

This theme support SEO elements for your website.
It was adapted and integrated thanks to the following guide:
[https://keithpblog.org/post/hugo-website-seo/](https://keithpblog.org/post/hugo-website-seo/)

If you wish to enable SEO on this theme, follow these instructions:
1. To include the following parameters in your _config.toml_
```
# .config.toml
...
enableRobotsTXT = true
canonifyURLs = true
# and if you think your md file names or locations might change:
[permalinks]
post = "/blog/:title/"
...
```

2. Add your website to Google Search Console:
- Login to the [Google Search Console](https://www.google.com/webmasters/tools/home)
- Add your website as property
- Add the html page as required by google to verify ownership
- Submit the sitemap (/sitemap.xml) for indexing
- Wait

3. Add your website to Bing
- Login to the [Bing Webmaster Console](https://www.bing.com/toolbox/webmaster/)
- Add your site, details and verify
- From the 3 option, we recommend adding the xml file to you website

## Shortcodes
In addition to the native [Hugo shortcodes](https://gohugo.io/extras/shortcodes/),
the theme also includes the following codes that I hope you find useful:
Expand Down
3 changes: 3 additions & 0 deletions exampleSite/config.toml
Expand Up @@ -7,6 +7,9 @@ paginate = 3
disqusShortname = "shortname"
googleAnalytics = ""
pluralizeListTitles = false
# Set the followings to true as part of your site SEO
enableRobotsTXT = true
canonifyURLs = true

[params]
# Sets the meta tag description
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/header.html
Expand Up @@ -6,6 +6,7 @@
-->
<html>
<head>
{{ partial "seo_schema" . }}
{{ with $.Scratch.Get "generalTitle" }}
<title>{{ . }}</title>
{{ else }}
Expand Down
26 changes: 26 additions & 0 deletions layouts/partials/seo_schema.html
@@ -0,0 +1,26 @@
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "BlogPosting",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ .Site.BaseURL }}"
},
"articleSection" : "{{ .Section }}",
"name" : "{{ .Title }}",
"headline" : "{{ .Title }}",
"description" : "{{ if .Description }}{{ .Description }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ end }}{{ end }}",
"inLanguage" : "{{ .Lang }}",
"author" : "{{ range .Site.Author }}{{ . }}{{ end }}",
"creator" : "{{ range .Site.Author }}{{ . }}{{ end }}",
"publisher": "{{ range .Site.Author }}{{ . }}{{ end }}",
"accountablePerson" : "{{ range .Site.Author }}{{ . }}{{ end }}",
"copyrightHolder" : "{{ range .Site.Author }}{{ . }}{{ end }}",
"copyrightYear" : "{{ .Date.Format "2006" }}",
"datePublished": "{{ .Date }}",
"dateModified" : "{{ .Date }}",
"url" : "{{ .Permalink }}",
"wordCount" : "{{ .WordCount }}",
"keywords" : [ {{ if isset .Params "tags" }}{{ range .Params.tags }}"{{ . }}",{{ end }}{{ end }}"Blog" ]
}
</script>

0 comments on commit 020882f

Please sign in to comment.