Skip to content

Can't add value from Params to a Date using AddDate #14079

@mwegnr

Description

@mwegnr

What version of Hugo are you using (hugo version)?

$ hugo version
0.152.0

Does this issue reproduce with the latest release?

Yes, it first occured with the latest release

Description

Previously, integer-Params defined in the Front-Matter could be added directly to a date with AddDate 0 0 .Params.int_param. This is broken in 0.152.0 since the param is now parsed as uint64 and AddDate expects an int

Example Code

Front-Matter:

---
title: Homepage
test_param_int: 4
---

list.html:

  {{ $test_date := time.Now }}
  Date + 2: {{ $test_date.AddDate 0 0 2 | time.Format ":date_medium" }}<br> {{/*  <- works  */}}
  Date + Param.test_param_int: {{ $test_date.AddDate 0 0 (.Params.test_param_int) | time.Format ":date_medium" }}<br> {{/*  <- breaks  */}}

Error message:

ERROR Rebuild failed: render: failed to render pages: render of "/srv/hugo/content/_index.md" failed: "/srv/hugo/layouts/list.html:8:65": execute of template failed at <.Params.test_param_int>: wrong type for value; expected int; got uint64

Example Hugo Page

https://github.com/mwegnr/hugo-uint64-int-param

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions