# Displaying author and date in content

**URL:** <https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505>\
**Category:** Using Themes\
**Created:** [August 29, 2021, 9:33pm UTC](https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505 "2021-08-29T21:33:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jehoshua7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jehoshua7/32/13763_2.png) [@jehoshua7](https://discourse.gohugo.io/u/jehoshua7)\
**Post date:** [August 29, 2021, 9:33pm UTC](https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505/1 "2021-08-29T21:33:53Z")

</div>

I’m using the [relearn theme](https://github.com/McShelby/hugo-theme-relearn) , which is a fork of the learn theme.

If an .MD file has author and date, how do I display the author and date as shown in an example at [Format usage](https://tshark.dev/formats/format_usage/) please ?

I have seen this done in a number of other themes.

---

<div class="post-metadata">

**Author:** ![jehoshua7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jehoshua7/32/13763_2.png) [@jehoshua7](https://discourse.gohugo.io/u/jehoshua7)\
**Post date:** [August 29, 2021, 10:42pm UTC](https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505/2 "2021-08-29T22:42:18Z")

</div>

If I look at the [Bootstrap blog theme](https://github.com/razonyang/hugo-theme-bootstrap) at [Online IDE Shortcodes - Hugo Bootstrap](https://hbs.razonyang.com/en/posts/shortcodes/online-ide/) , it uses a Boolean value of `postDate` to control the display of date and reading time, etc

In /layouts/partials/post/meta.html

```auto
<div class="post-meta mb-3">
  {{- if and (default true (default .Site.Params.postDate .Params.postDate)) -}}
  <span class="post-date me-2">
    <i class="fas fa-fw fa-calendar-alt"></i>{{ .Date.Format (default "Jan 2, 2006" $.Site.Params.dateFormat) }}
  </span>
  {{- end -}}
  {{- if and (default true (default .Site.Params.readingTime .Params.readingTime)) -}}
  <span class="post-reading-time me-2">
    <i class="fas fa-fw fa-coffee"></i>{{ i18n "reading_time" . }}
  </span>
  {{- end -}}
  <span class="post-taxonomies">
  {{- range $key, $value := .Site.Taxonomies -}}
    {{- range ($.GetTerms $key) -}}
    <a href="{{ .Permalink }}" class="post-taxonomy">{{ .Name }}</a>
    {{- end -}}
  {{- end -}}
  </span>
</div>

```

---

<div class="post-metadata">

**Author:** ![jehoshua7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jehoshua7/32/13763_2.png) [@jehoshua7](https://discourse.gohugo.io/u/jehoshua7)\
**Post date:** [August 30, 2021, 3:16am UTC](https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505/3 "2021-08-30T03:16:46Z")

</div>

Have checked with the author of the [TShark site](https://tshark.dev/formats/format_usage/) , and the front matter I’m using in the .MD files are the same formats.

So, there must be either a slight code difference between the **learn** and **relearn** themes, or some config setting, or both maybe ?

An interesting read on front matter at [Front Matter | Hugo](https://gohugo.io/content-management/front-matter)

---

<div class="post-metadata">

**Author:** ![funkydan2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/funkydan2/32/5636_2.png) [@funkydan2](https://discourse.gohugo.io/u/funkydan2)\
**Post date:** [August 30, 2021, 5:39am UTC](https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505/4 "2021-08-30T05:39:21Z")

</div>

From what I can tell of the theme’s documentation, this isn’t a feature of the theme. If you want pages to display author and date based on frontmatter, you’ll have to edit the theme yourself.

I’d be looking at overriding either `tags.html` and/or `header.html`.

To _override_ something from the theme, make a copy of the file from the theme (e.g. `/themes/hugo-theme-relearn/layouts/partials/tags.html` and put it in `layouts/partials/tags.html`. Then edit ‘your’ version of the file to include author name and date.

If you incorporate some of the things you’ve seen in the other theme’s you’ve linked to, you should be able to work it out.

---

<div class="post-metadata">

**Author:** ![jehoshua7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jehoshua7/32/13763_2.png) [@jehoshua7](https://discourse.gohugo.io/u/jehoshua7)\
**Post date:** [August 30, 2021, 6:06am UTC](https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505/5 "2021-08-30T06:06:38Z")

</div>

@funkydan2 Thanks for your help and those tips

> If you incorporate some of the things you’ve seen in the other theme’s you’ve linked to, you should be able to work it out.

I’ve installed a theme where the front matter details are displayed ( [hugo-theme-bootstrap](https://github.com/razonyang/hugo-theme-bootstrap) ), so should be able to work out how it is done. Just how well that will ‘fit’ into the **relearn** theme though I don’t know yet.

---

<div class="post-metadata">

**Author:** ![McShelby](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mcshelby/32/15112_2.png) [@McShelby](https://discourse.gohugo.io/u/McShelby)\
**Post date:** [August 30, 2021, 3:20pm UTC](https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505/6 "2021-08-30T15:20:13Z")

</div>

Hey @jehoshua7, partials aren’t well documented at the moment. Addtionally, the content partial was newly introduced with the last release.

Create a new file `layouts/partials/content.html` in your site’s root directory with the following content:

```auto
{{- .Content -}}

<div class="author">{{- .Params.author -}}</div>

```

Add a `author` field to the front matter in each of your pages.

That should do the job.

---

<div class="post-metadata">

**Author:** ![jehoshua7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jehoshua7/32/13763_2.png) [@jehoshua7](https://discourse.gohugo.io/u/jehoshua7)\
**Post date:** [August 31, 2021, 3:21am UTC](https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505/7 "2021-08-31T03:21:49Z")

</div>

Thanks @McShelby . That works fine, and I added the date …

```auto
<div class="page-description"><i class="fas fa-clock"></i> {{ .ReadingTime }} min | <i class="fas fa-feather-alt"></i> {{ .Params.Author }} | <i class="far fa-calendar-check"></i> {{ .Date.Format "January 1, 2006"}}</div>

{{- .Content -}}

```

Not sure if it needs other (conditional) code, as not everyone wants this displayed in the content.

Thanks for your help. 😄

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [September 2, 2021, 3:22am UTC](https://discourse.gohugo.io/t/displaying-author-and-date-in-content/34505/8 "2021-09-02T03:22:10Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
