From b12d2510f91c49154d82750ded286d3265a5c9b8 Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Sun, 10 May 2020 05:23:02 +0100 Subject: [PATCH] Updating documentation --- blog/hugolayout.md | 157 +++++++++++++++++++++++++++++++++++++++++++++ tasks.todo | 6 ++ 2 files changed, 163 insertions(+) diff --git a/blog/hugolayout.md b/blog/hugolayout.md index d6ddda1..6989a37 100644 --- a/blog/hugolayout.md +++ b/blog/hugolayout.md @@ -536,6 +536,26 @@ Create a `schema.html` file in `./layouts/partials/`. An example file for an article is: . +You **need to make sure** that there is an `_index.md` in `./content/post/` which defines front matter for the `list.html`. The `schema.html` references `"image": {{ index .Params.images 0 | absURL }},` which will be checked on the `list` page because its section is equal to `post`. If you ommit this then Hugo will fail to build and give a `: error calling index: index of untyped nil` error. + +Set the relevant parameters in the `config.toml`: + +```toml +baseURL = "https://weekinmemes.com" + +[params] +author = "DK" +logo = "img/logo.jpg" +header = "Week In Memes" + +facebook = "weekinmemes" +twitter = "weekinmemes" +instagram = "weekinmemes" +github = "weekinmemes" +``` + +You should test your structured data against: . Make sure that it is recognising all contexts you've defined. Your object should be valid json so make sure there is a parent array with commas seperating the objects. + #### Generic meta tags The following should go in your `` block: @@ -594,3 +614,140 @@ This description should be no more than 155 characters and a few sentences. It s ``` + +#### Languages + + + + + +You should set in your `config.toml`: + +```toml +[languages] +[lanugages.en] +weight = 1 +[languages.en.params] +LanguageName = "English" +``` + +And the following at the top level (root no header): + +```toml +languageCode = "en" +DefaultContentLanguage = "en" +``` + +Then in the `head.html`: + +```html + + +{{ range .AllTranslations }} + +{{ end }} +``` + +#### Images + +Add the following to `head.html` + +```hugo + +{{ with .Params.images }} +{{ $image := index . 0 }} + + + + +{{ else }} + + + + +{{ end }} +``` + +We are using the `homepageimage` and the first image of the `images` array for any list content. + +#### Date + +We set the property of updated time and get the sitemap for the whole site, and for the page we are on. + +```hugo + + + + +{{ with .OutputFormats.Get "RSS" }} + + +{{ end }} +``` + +#### Article pages + +These tags set the pagination, the publish time and author information. These should only be for blog posts or articles, not single pages like `home` or `about`. + +This should be set for each `.Section` that is an article type, in this case it is just `post`. + +```hugo + +{{ if eq .Section "post" }} + + {{ $paginator := .Paginate (where .Pages "Section" "post") }} + {{ if $paginator }} + + + {{ if $paginator.HasPrev }} + + {{end }} + {{ if $paginator.HasNext }} + + {{end }} + {{end }} + + + + + {{ if .Params.authors }} + {{ $authors := delimit .Params.authors ", " }} + + + + {{ else }} + {{ $authors := .Site.Params.author }} + + + + {{ end }} +{{ end }} +``` + +#### Single pages + +These should only be set on pages that are not articles. To do this we can use Hugo's scratch. + +You should set `{{ .Scratch.Set "IsSingle" true }}` on the following templates: + +- `./layouts/index.html` which is for the homepage. +- `./layouts/_default/single.html` which is for single pages like `About`. + +For each article you need to make sure the `single.html` is set it is own folder where this isn't set. For example `./layouts/post/single.html` exists and does not set it. + +You need to make sure the right context is passed into the partial if you do this. + +Alternatively, you can do: + +```hugo + +{{ if ne .Section "post" }} + + +{{ end }} +``` diff --git a/tasks.todo b/tasks.todo index 3b0626c..b5c76d8 100644 --- a/tasks.todo +++ b/tasks.todo @@ -63,8 +63,14 @@ Tasks: ☐ Document + Set all metadata using https://www.skcript.com/svr/perfect-seo-meta-tags-with-hugo/ ☐ Change the manifest.json ☐ Set the favicon and apple-touch-icons + ☐ Fix the structured data + ☐ Finish the metadata + document + ☐ Create social media accounts for the site and add to structured data + config.toml CI: ☐ Use circle CI to deploy Notes: Make sure we run `yarn build` on the theme first. + + Final build: + ☐ Change the front matter for `_index.md` in `post`.