# Content: is it same for Page and Post? And how to hide date

**URL:** <https://discourse.gohugo.io/t/content-is-it-same-for-page-and-post-and-how-to-hide-date/2246>\
**Category:** support\
**Created:** [December 9, 2015, 7:12am UTC](https://discourse.gohugo.io/t/content-is-it-same-for-page-and-post-and-how-to-hide-date/2246 "2015-12-09T07:12:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![askar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/askar/32/602_2.png) [@askar](https://discourse.gohugo.io/u/askar)\
**Post date:** [December 9, 2015, 7:12am UTC](https://discourse.gohugo.io/t/content-is-it-same-for-page-and-post-and-how-to-hide-date/2246/1 "2015-12-09T07:12:38Z")

</div>

Hello!

I’m about confused.

When we create content via `huge new something.md` it creates content with  
`date = "2015-12-09T15:03:01+09:00"` and shows it up, but I may not want to show the date.  
This would be ok if I’m making a blog post.

Do we create a page also via `huge new something.md` ? If yes, is there a way to hide date?  
Removing the filed, still shows up but with the default date.

Thanks.

**UPDATE:**

It seems hiding/showing date is set by the  
`<span class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>`  
so removing this line can hide a date.

_Please correct me if I’m wrong._

---

<div class="post-metadata">

**Author:** ![moorereason](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/moorereason/32/592_2.png) [@moorereason](https://discourse.gohugo.io/u/moorereason)\
**Post date:** [December 9, 2015, 9:36am UTC](https://discourse.gohugo.io/t/content-is-it-same-for-page-and-post-and-how-to-hide-date/2246/2 "2015-12-09T09:36:37Z")

</div>

You’re correct. Every page has a date, even if you don’t set it explicitly. The layouts and/or theme controls whether it is displayed or not.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [December 9, 2015, 7:08pm UTC](https://discourse.gohugo.io/t/content-is-it-same-for-page-and-post-and-how-to-hide-date/2246/3 "2015-12-09T19:08:10Z")

</div>

@askar To expand a little on @moorereason 's response:

I’m assuming that `<span class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>` is from a Hugo theme that you’ve downloaded. Although you may not want to have the date write to the page for your end-user, you’ll eventually be grateful that this little chunk of metadata is included in all of your content files.

You mentioned that writing the date to the page “would be okay if making a blog post,” so I’m assuming you’ll need it for some of your content. If you want to set this at the page/layout level, you can add page/content-specific metadata in the toml/yaml head of your new `.md` file and then create a conditional statement for displaying the date.

For yaml:

```auto
---
title: "My Blog Post"
date: "2015-12-09T15:03:01+09:00"
showthedate: true
---

```

For TOML:

```auto
title = "My Blog Post"
date = "2015-12-09T15:03:01+09:00"
showthedate = true

```

You can make this easier by deciding if you want a default value for particular sections. So, for example, you may want all posts to show the date (you can also use [.PublishDate](http://gohugo.io/templates/variables/#page-variables:2b8b8ac4006be88c769f5e3fd99b009a), which is a built-in page variable with Hugo) by default and create a file in your `archetypes` folder named `post.md` that shows that looks like the following:

```auto
---
showthedate: true
---

```

Which will create a file that includes both the title and date by default and then will add your new param each time you create a new post from the command line.

Now you can access this little chunk of metadata using Go templating logic as follows:

```auto
{{ if .Params.showthedate }}
<span class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
{{ end }}

```

If you want to give yourself the opportunity to turn off all dates site-wide by changing a single variable but also leave yourself the granular control on a per-page basis, you could create a site variable in your config file (toml or yaml). You wouldn’t want to do this for dates, but you may have other use cases (eg, wanting to turn off all comments at once for something like Disqus) and it will help give you an idea of the difference between site variables and page variables:

####TOML

```auto
#This would be in your config.toml file at your root
[params]
    ShowDatesOnPosts = true

```

####YAML

```auto
#This would bet in your config.yaml file at your root

params:
- ShowDatesOnPosts: true

```

You could then set this in your templating logic to look for _both_ conditions:

```auto
{{ if and (.Params.showthedate) (.Site.Params.ShowDatesOnPosts) }}
<span class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
{{ end }}

```

Even if you have 10k posts, all you would need to do is change the `ShowDatesOnPosts` to `false` in your `config.yaml/toml` and _all_ dates would be removed from your end-user.

**Gotcha:** Note that your page-level variables (in this instance, `.Params.showthedate`) **_must be set in lowercase in your templating logic._**

Hope that helps. Cheers.

---

<div class="post-metadata">

**Author:** ![askar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/askar/32/602_2.png) [@askar](https://discourse.gohugo.io/u/askar)\
**Post date:** [December 10, 2015, 12:25am UTC](https://discourse.gohugo.io/t/content-is-it-same-for-page-and-post-and-how-to-hide-date/2246/4 "2015-12-10T00:25:21Z")

</div>

@rdwatters - Thanks for the detailed answer!

---

<div class="post-metadata">

**Author:** ![nish](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@nish](https://discourse.gohugo.io/u/nish)\
**Post date:** [August 15, 2019, 5:50pm UTC](https://discourse.gohugo.io/t/content-is-it-same-for-page-and-post-and-how-to-hide-date/2246/5 "2019-08-15T17:50:31Z")

</div>

You can also create a condition with a default value, then on the pages/posts which you do/don’t want to show the date, you can mention it. This method will help you save some time by not adding the variable on every single .md file.

First you add the conditional value with the default value as “true” or “false”. This depends on the statement you are trying to do…

```
{{ if .Params.showthedate | default "true" }}
<span class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
{{ end }}

```

On the pages or posts where you don’t want to show the date, you need to add the variable as follows.

```
+++
title = "About"
description = "Hugo, the world’s fastest framework for building websites"
date = "2019-02-28"
showthedate = false
+++

```

On the able example, if you don’t mention the showthedate option, it will use the default value, in this case “true”.

I hope this example helps someone.

---

<div class="post-metadata">

**Author:** ![ju52](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ju52/32/6749_2.png) [@ju52](https://discourse.gohugo.io/u/ju52)\
**Post date:** [August 15, 2019, 6:08pm UTC](https://discourse.gohugo.io/t/content-is-it-same-for-page-and-post-and-how-to-hide-date/2246/6 "2019-08-15T18:08:15Z")

</div>

> [@rdwatters](#):
>
> {{ if .Params.showthedate }}

use `{{ with .Params.showthedate }} .. {{end}}` it wille be true if you have defined **showthedate**

> **[with](https://gohugo.io/functions/go-template/with/)**
>
> Binds context (the dot) to the expression and executes the block if expression is truthy.

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [August 15, 2019, 8:04pm UTC](https://discourse.gohugo.io/t/content-is-it-same-for-page-and-post-and-how-to-hide-date/2246/7 "2019-08-15T20:04:47Z")

</div>


