Skip to content

Commit

Permalink
Handle updating a post
Browse files Browse the repository at this point in the history
If a post has been updated, display the date it was updated, along with
the date it was originally published. Hugo automtically updates the
lastmod value in the sitemap, so we don't have to worry about that.

For crawlers, add HTML time tags, along with "datePublished" and
"dateModified" microdata attributes. Currently, Google isn't displaying
the dates of the posts in the search results. Maybe these changes will
fix that.
  • Loading branch information
dguo committed Jan 30, 2019
1 parent 22181fd commit 86db8a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Many of these were easy to add because of Hugo.
* [mini blog of issues I've run into while programming](https://www.dannyguo.com/friction/)
* [referral links](https://wwww.dannyguo.com/referrals/)

## Publishing Checklist
## Checklist for Publishing a Post

1. Upload any images to the dedicated [Imgur album](https://imgur.com/a/mA7JRWp)
2. Publish the post by removing the `draft` flag
Expand All @@ -67,6 +67,17 @@ Many of these were easy to add because of Hugo.
* [Reddit](https://www.reddit.com/)
* [Twitter](https://twitter.com/)

## Checklist for Updating a Post

Only do this for substantial changes, not small ones like fixing typos or links.

1. Add the `lastmod` variable to the post's [front
matter](https://gohugo.io/content-management/front-matter/#front-matter-variables)
2. Update the post content
3. Publish it
4. If applicable, update the Medium post and/or the dev.to post
* Make sure to check embedded content, like code examples

## License

The content of this project (in the `content` directory) is licensed under the
Expand Down
9 changes: 6 additions & 3 deletions layouts/blog/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
{{ end }}

{{ define "main" }}
<h1>{{ .Title }}</h1>
<div class="subheader">{{.Date.Format "January 2, 2006"}}&nbsp;&nbsp;·&nbsp;&nbsp;{{ .WordCount | lang.NumFmt 0 }} words&nbsp;&nbsp;·&nbsp;&nbsp;~{{ .ReadingTime | lang.NumFmt 0 }} minute{{ if not (eq .ReadingTime 1) }}s{{ end }} to read</div>
<article>
<h1>{{ .Title }}</h1>

{{ partial "anchor.html" .Content }}
<div class="subheader">{{ if ne .Date .Lastmod }}Updated on <time itemprop="dateModified" datetime="{{ .Lastmod.Format "2006-01-02" }}">{{ .Lastmod.Format "January 2, 2006" }}</time>&nbsp;&nbsp;·&nbsp;&nbsp;Published on {{ end }}<time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02" }}">{{.Date.Format "January 2, 2006"}}</time>{{ if eq .Date .Lastmod }}&nbsp;&nbsp;·&nbsp;&nbsp;{{ else }}<br>{{ end }}{{ .WordCount | lang.NumFmt 0 }} words&nbsp;&nbsp;·&nbsp;&nbsp;~{{ .ReadingTime | lang.NumFmt 0 }} minute{{ if not (eq .ReadingTime 1) }}s{{ end }} to read</div>

{{ partial "anchor.html" .Content }}
</article>

<hr class="separator">

Expand Down

0 comments on commit 86db8a3

Please sign in to comment.