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 #1

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

Errors on site without expected parameters set #1

paskal opened this issue Mar 20, 2018 · 4 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:

Building sites … ERROR 2018/03/20 20:35:56 Error while rendering "page" in "": template: /srv/hugo/themes/hyde-hyde/layouts/_default/single.html:6:7: executing "content" at <partial "post_conten...>: error calling partial: template: theme/partials/post_content.html:22:21: executing "theme/partials/post_content.html" at <len .Params.tags>: error calling len: len of untyped nil
ERROR 2018/03/20 20:35:56 Error while rendering "page" in "post/": template: /srv/hugo/themes/hyde-hyde/layouts/_default/single.html:6:7: executing "content" at <partial "post_conten...>: error calling partial: template: theme/partials/post_content.html:22:21: executing "theme/partials/post_content.html" at <len .Params.tags>: error calling len: len of untyped nil

The reason is absent .Params.tags parameter for some unknown post but you can't tell by which from error message, I guess input parameters handling could be improved. cboettig/hugo-now-ui#9 might be used as reference point.
My suggestion is to threat tags absence as zero-length array.

@paskal
Copy link
Author

paskal commented Mar 24, 2018

victoriadrake/hugo-theme-sam#3 is an example of how this can be fixed.

@htr3n
Copy link
Owner

htr3n commented Mar 30, 2018

Thanks @paskal so much for your time investigating and reporting the bugs. This is actually the point I have been very careful when porting themes from other people, especially in case of hyde-hyde. I included several conditional checks {{ if ... }} but it seems there are problems with {{ if isset ... }} (there are a number of issue reports on isset, for instance here or here). The error is exactly at the line {{ $total := len .Params.tags }} whilst there is {{ if isset .Params.tags }} right before that.

I switched to {{ with .... }} and it seems to work for now, at least with the example site you provided. Thanks again.

@htr3n htr3n closed this as completed in 26effad Mar 30, 2018
@paskal
Copy link
Author

paskal commented Mar 30, 2018

Thanks a lot! I've seen this problem around and now I can reference your investigation in fixing these bugs around.

@htr3n
Copy link
Owner

htr3n commented Mar 30, 2018

@paskal : awesome.

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

2 participants