Closed RichardDooling closed 10 years ago
Disclaimer: it's been months since I used hugo. The last time I used it, the themes hadn't been implemented yet, so I don't really know how this feature works... I'll see what I can do about this issue regardless.
Error suggests DateForm
is the wrong type... could I see your config.json
(or equivalent yaml/toml)? Looks like I never wrote any documentation for this, but basically the DateForm
is an entry in the global configuration for the theme. It controls the way dates are printed and formatted.
I just changed it to a date string. I just wanted to see what it looked like and it would not build. Now I got it working. Thanks. Looks nice!
Phew, glad you got it fixed! For future reference, you can read about the valid strings here.
Hi, I am facing the same problem. I added the "DateForm"="ANSIC"
to my config.toml
file but it doesn't work still. Is there anything else I should do?
Thanks.
The thing is that ANSIC
is a Go constant that happens to equal a valid date/time format string. It's not a valid string in and of itself. You need to set DateForm to the value of ANSIC
, ie "Mon Jan _2 15:04:05 2006"
.
how we should fix <.Site.Params.DateFor...>: invalid value; expected string
??
What's in your config.json
or equivalent?
config.toml
baseurl = "http://yourSiteHere"
languageCode = "en-us"
title = "My Blog"
You need a DateForm
key in there, eg DateForm = "Jan 2 2006"
. Take a look at the config.json
in this repository.
Btw PRs are welcome to set a default dateform in the layouts, but I don't use Hugo anymore so making this easier is really not a priority for me.
I added this (DateForm = "Jan 2 2006"
) to my config.toml
, restarted the server and nothing is fixed. I tried the other values here too.
what's the error message you're seeing and what's the full content of your config file?
It was the same error message†, config.toml
:
baseurl = "http://promisekit.org/"
languageCode = "en-us"
title = "PromiseKit"
PygmentsCodeFences = true
DateForm = "Mon Jan _2 15:04:05 2006"
† ERROR: 2016/07/15 17:59:55 general.go:222: Error while rendering page fundamentals/introduction.md: template: theme/_default/single.html:5:47: executing "theme/_default/single.html" at <.Site.Params.DateFor...>: invalid value; expected string
Ah, DateForm
needs to be under params
, not the top level. Try:
baseurl = "http://promisekit.org/"
languageCode = "en-us"
title = "PromiseKit"
PygmentsCodeFences = true
[params]
DateForm = "Mon Jan _2 15:04:05 2006"
Terrific, thanks.
I already had this:
[params]
DateForm = "Mon Jan 2, 2006"
But that did not work!
Turns out that even though you call it .Site.Params.DateForm
, that params
needs to be lower case in config.toml
.
[params]
DateForm = "Mon Jan 2, 2006"
[Params] # capitalized does not work
DateForm = "Mon Jan 2, 2006"
I got the same problem with Hugo v.0.18-DEV. My configuration file:
baseurl = "http://luizdepra.com/"
title = "luizdepra"
theme = "lanyon"
languagecode = "en-us"
canonifyurls = true
pygmentsuseclasses = true
pygmentscodefences = true
[permalinks]
post = ":year/:month/:day/:title/"
fixed = ":title/"
[params]
Title = "luizdepra"
Tagline = "a sip of FUNgramming"
Author = "Luiz de Prá"
DateForm = "Jan 2, 2006"
I solved it changing .Site.Params.DateForm
to .Site.Params.dateform
. Have Hugo changed something in this last version?
On Mac OSX Mavericks, if I do
hugo server --theme=lanyon --buildDrafts --watch
ERROR: 2014/09/30 Rendering error: template: theme/post/single.html:5:47: executing "theme/post/single.html" at <.Site.Params.DateFor...>: invalid value; expected string
ERROR: 2014/09/30 Rendering error: template: theme/index.html:10:53: executing "theme/index.html" at <.Site.Params.DateFor...>: invalid value; expected string