On some pages, the date doesn't need to be there
vinliao opened this issue · comments
There's no point in having date shown in some pages - for example, an about page. Removing date on the markdown's front matter would make it 0001-01-01
.
What's the best possible way to go about doing this?
(Not a terribly critical issue; just a nice to have feature.)
I solved this by setting a variable inside the frontmatter. Something like „showdate: True“ and in the template simply query the variable with if, then, else.
Well, hey, thank you @saschadieter for the idea.
I found an easier solution.
In single.html
:
{{ if .Params.Date }}
<p datetime="{{ .Date.Format " 2006-01-02T15:04:05Z07:00" }}" class="post-date">
{{ .Date.Format "2006-01-02" }}
</p>
{{ end }}
By doing this, the date won't be there just by deleting the date
variable in the front matter.
(It works, but the padding margin looks a little bit off. Will make a PR once this is fixed.)
Well, I guess that separates a full on developer from a technical writer.