I am using the RStudio> RMarkdown> Blogdown> Github> Netlify flow to publish a website.
The top of the RMarkdown document has yaml to define the title, description, and keywords, like so:
---
title: "The Best GIC and Savings Rates in Canada"
description: "WhatBank compares the best GIC and high-interest savings accounts in Canada. Setup personalized email notifications to stay informed."
keywords: "gic, gics, term deposit, guaranteed investment certificate, rates, canada, comparison, compare, highest, best, email alerts, 1 year, 2, year, 3 year, 4 year, 5 year, long term, high-interest, savings, high-interest savings"
author: "WhatBank"
date: "2021-03-27"
slug: "home"
output:
html_document:
includes: header.html
---
This seems to work OK for every page except the home page. I think that this has to do with the file: layouts/partials/head.html
At some point, the title tag was edited:
<meta charset="utf-8">
<title>{{ if .IsHome }}Highest GIC and Savings Rates in Canada - {{ else }}{{ if .Page.Title }}{{ .Page.Title }} - {{ end }}{{ end }}{{ .Site.Title }}</title>
<!--
<title>{{ if .Page.Title }}{{ .Page.Title }} - {{ end }}{{ .Site.Title }}</title>
-->
<meta name="description"
content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}">
{{ with .Site.Params.author }}
<meta name="author" content="{{ . }}">{{ end }}
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords"
content="{{ with .Keywords }}{{ . }}{{ else }}{{ with .Site.Params.keywords }}{{ . }}{{ end }}{{ end }}">
...
The above hardcoded title works but is not ideal because it is hardcoded. More importantly, the description and keywords tags are empty when I View Source:
<meta name="description"
content="">
<meta name="keywords"
content="">
and author never appears on any page, but I’m not sure that is important since this is a website and not a blog.
Question: How do I modify head.html so the HTML of every page will have the title, description and keywords that are reflected in the yaml of the RMarkdown pages?
hugo env
Hugo Static Site Generator v0.79.1-EDB9248D/extended linux/amd64 BuildDate: 2020-12-19T15:50:19Z
GOOS=“linux”
GOARCH=“amd64”
GOVERSION=“go1.15.1”
git version 2.25.1