cboettig / hugo-now-ui

:globe_with_meridians: Hugo adaptation of Now-UI from Creative Tim
http://cboettig.github.io/hugo-now-ui
MIT License
97 stars 61 forks source link

Errors on site without expected parameters set #9

Closed paskal closed 6 years ago

paskal commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

https://github.com/kaushalmodi/hugo-bare-min-theme/issues/1 might be a good reference point.

cboettig commented 6 years ago

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 commented 6 years ago

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! https://github.com/gohugoio/hugo/issues/4490

Source

paskal commented 6 years ago

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 commented 6 years ago

Thanks very much... More coming soon.

On Mar 20, 2018 10:39, "Dmitry Verkhoturov" notifications@github.com wrote:

Look what I've found:

[image: image] https://user-images.githubusercontent.com/712534/37672246-9d7850c8-2c7e-11e8-8d20-54935d2e5e6d.png https://github.com/solutionroute/hugo-smorg by @solutionroute https://github.com/solutionroute is amazing.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cboettig/hugo-now-ui/issues/9#issuecomment-374690039, or mute the thread https://github.com/notifications/unsubscribe-auth/AD7VniSyznoH3FjWcI6URAWouX8gRIHVks5tgT7LgaJpZM4SyTEf .

paskal commented 6 years ago

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

paskal commented 6 years ago

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 https://github.com/paskal/terrty/issues/1.