Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors on site without expected parameters set #9

Closed
paskal opened this issue Mar 20, 2018 · 8 comments
Closed

Errors on site without expected parameters set #9

paskal opened this issue Mar 20, 2018 · 8 comments

Comments

@paskal
Copy link

paskal commented Mar 20, 2018

Hello!

$subj, when trying to run this theme against my blog source I get following (and site won't render at all):

Building sites … ERROR 2018/03/20 16:00:31 Error while rendering "page" in "": template: /srv/hugo/themes/hugo-now-ui/layouts/_default/single.html:11:152: executing "/srv/hugo/themes/hugo-now-ui/layouts/_default/single.html" at <relURL>: wrong number of args for relURL: want 1 got 0
ERROR 2018/03/20 16:00:31 Error while rendering "page" in "post/": template: /srv/hugo/themes/hugo-now-ui/layouts/_default/single.html:11:152: executing "/srv/hugo/themes/hugo-now-ui/layouts/_default/single.html" at <relURL>: wrong number of args for relURL: want 1 got 0
ERROR 2018/03/20 16:00:31 Error while rendering "taxonomy" in "": template: /srv/hugo/themes/hugo-now-ui/layouts/_default/list.html:11:152: executing "/srv/hugo/themes/hugo-now-ui/layouts/_default/list.html" at <relURL>: wrong number of args for relURL: want 1 got 0
ERROR 2018/03/20 16:00:31 Error while rendering "section" in "": template: /srv/hugo/themes/hugo-now-ui/layouts/_default/list.html:11:152: executing "/srv/hugo/themes/hugo-now-ui/layouts/_default/list.html" at <relURL>: wrong number of args for relURL: want 1 got 0
ERROR 2018/03/20 16:00:31 Error while rendering "taxonomyTerm" in "": template: /srv/hugo/themes/hugo-now-ui/layouts/_default/terms.html:11:152: executing "/srv/hugo/themes/hugo-now-ui/layouts/_default/terms.html" at <relURL>: wrong number of args for relURL: want 1 got 0

The reason is likely some absent .Site. parameter but you can't tell it from error message, I guess input parameters handling could be improved.

@cboettig
Copy link
Owner

Thanks for the bug report. Yeah, all the templates want a background parameter defined in the config, e.g.: https://github.com/cboettig/hugo-now-ui/blob/master/exampleSite/config.toml#L74

This value is used as the default; it can be overridden by the page level parameters / yaml headers. But I see your point that I really ought to have a fallback for when neither can be found. Not quite sure the Hugo-foo for that case. Here's the relevant line in the template:

https://github.com/cboettig/hugo-now-ui/blob/master/layouts/_default/baseof.html#L11

@paskal
Copy link
Author

paskal commented Mar 20, 2018

kaushalmodi/hugo-bare-min-theme#1 might be a good reference point.

@cboettig
Copy link
Owner

Thanks! Yes, I definitely agree the theme should at least build without errors given a vanilla / no config.yml. (Some documentation of parameter use in the README is also needed).

I'll take a whack at this

@kaushalmodi
Copy link

Here's the relevant line in the template:

This does not solve the problem at hand.. but here's a minor optimization to prevent having that | default.

If you do {{ .Param "foo" }}, it will pick the foo param from the .Page.Params context if found.. and if not, it looks in .Site.Params context.

So you can do {{ .Param "background" | relURL }} instead of {{ .Params.background | default .Site.Params.background | relURL }}.


Now to tackle the problem at hand, you can probably:

  1. Commit the default image to your theme/static/img/foo.png, and then
  2. {{ (.Param "background") | default "img/foo.png" | relURL }} (I haven't tried that.. but should work)

On that note, this upcoming feature in Hugo will help a great deal! gohugoio/hugo#4490

Source

@paskal
Copy link
Author

paskal commented Mar 20, 2018

Look what I've found:

image
https://github.com/solutionroute/hugo-smorg by @solutionroute is amazing.

Another way in https://github.com/olOwOlo/hugo-theme-even from @olOwOlo:

~  docker-compose run --publish 1111:1111  --rm --name hugo-theme-even blog-preview -D --port 1111 --bind "0.0.0.0" --theme hugo-theme-even server
Building sites … ERROR 2018/03/20 17:35:09

There are two possible situations that led to this error:
  1. You haven't copied the config.toml yet. See https://github.com/olOwOlo/hugo-theme-even#installation
  2. You have an incompatible update. See https://github.com/olOwOlo/hugo-theme-even/blob/master/CHANGELOG.md#300

@mwyvr
Copy link

mwyvr commented Mar 20, 2018 via email

@paskal
Copy link
Author

paskal commented Mar 20, 2018

Just checked, works like a charm after last commit. Thanks a lot!

@paskal
Copy link
Author

paskal commented Mar 24, 2018

I'm not sure github sent notifications to mentioned authors, so posting double there: theme highlight is out, this very theme is in it, additional info on paskal/terrty#1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants