# Unable to display the date correctly on a webpage

**URL:** <https://discourse.gohugo.io/t/unable-to-display-the-date-correctly-on-a-webpage/50390>\
**Category:** support\
**Created:** [June 22, 2024, 5:39pm UTC](https://discourse.gohugo.io/t/unable-to-display-the-date-correctly-on-a-webpage/50390 "2024-06-22T17:39:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahulgadre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rahulgadre/32/22363_2.png) [@rahulgadre](https://discourse.gohugo.io/u/rahulgadre)\
**Post date:** [June 22, 2024, 5:39pm UTC](https://discourse.gohugo.io/t/unable-to-display-the-date-correctly-on-a-webpage/50390/1 "2024-06-22T17:39:20Z")

</div>

This issue is related to a hugo site page hosted with GitHub pages.

The following is added in the metadata section of a blog.md file:

* * *

## title: Blog title date: 2023-09-10T12:12:25.364Z

The data on the blog page is getting displayed as shown below:

`<span title='2023-09-10 12:12:25.364 +0000 UTC'>September 10, 2023</span>`

I only want to keep September 10, 2023 and don’t want to include the rest on the blog page.

The html file from where it is fetching the data has the following code:

```auto
{{- if not .Date.IsZero -}}
{{- $scratch.Add "meta" (slice (printf "<span title='%s'>%s</span>" (.Date) (.Date | time.Format (default "January 2, 2006" .Site.Params.DateFormat)))) }}
{{- end }}

```

As part of troubleshooting, I have done several changes in the above code and the print statement, but couldn’t get the desired result. Any inputs or pointers on this will be helpful.

Thank you for your time!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 22, 2024, 5:56pm UTC](https://discourse.gohugo.io/t/unable-to-display-the-date-correctly-on-a-webpage/50390/2 "2024-06-22T17:56:47Z")

</div>

Which theme are you using?

---

<div class="post-metadata">

**Author:** ![rahulgadre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rahulgadre/32/22363_2.png) [@rahulgadre](https://discourse.gohugo.io/u/rahulgadre)\
**Post date:** [June 22, 2024, 6:04pm UTC](https://discourse.gohugo.io/t/unable-to-display-the-date-correctly-on-a-webpage/50390/3 "2024-06-22T18:04:45Z")

</div>

The theme is [hugo-theme-charlolamode](https://github.com/charlola/hugo-theme-charlolamode)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 22, 2024, 6:18pm UTC](https://discourse.gohugo.io/t/unable-to-display-the-date-correctly-on-a-webpage/50390/4 "2024-06-22T18:18:16Z")

</div>

That theme is out-of-date. Please log an issue with the theme author.

To fix the problem they need to pass the result of the delimit function through the safeHTML function.

For example, change this…

```plaintext
{{- with ($scratch.Get "meta") }}
  {{- delimit . "&nbsp;·&nbsp;" -}}
{{- end -}}

```

… to this:

```plaintext
{{- with ($scratch.Get "meta") }}
  {{- delimit . "&nbsp;·&nbsp;" | safeHTML -}}
{{- end -}}

```

They use the delimit function in several places.

---

<div class="post-metadata">

**Author:** ![rahulgadre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rahulgadre/32/22363_2.png) [@rahulgadre](https://discourse.gohugo.io/u/rahulgadre)\
**Post date:** [June 22, 2024, 9:02pm UTC](https://discourse.gohugo.io/t/unable-to-display-the-date-correctly-on-a-webpage/50390/5 "2024-06-22T21:02:56Z")

</div>

Thanks a lot, @jmooring🙂  
This solved the issue.

---

<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:** [June 24, 2024, 9:03pm UTC](https://discourse.gohugo.io/t/unable-to-display-the-date-correctly-on-a-webpage/50390/6 "2024-06-24T21:03:05Z")

</div>

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