Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

.Render in a theme displays as blank and also fail silently for non-existent views #303

Closed
whereisaaron opened this Issue · 10 comments

3 participants

@whereisaaron

Since switching to using a theme folder structure, I can no longer render views, they silently render as blank. I have tested with build from source and downloading 0.11.

I also realised that if I specify a view name the definitely does not exist, hugo still rendered the website without error or warning. If I change ".Render" to ".XRender" I do get an error. So it just seems to be ".Render" silently failing. Even if I am doing something wrong, I feel a missing view file should display a warning or error?

{{ .Render "BogusButCausesNoError" }}

I put my (previously working) view files in every possible folders lists in the documentation (http://hugo.spf13.com/templates/views), but where '{{ .Render "summary" }}' used to work, now it silently producing blank.

Here is the section of my 'index.html' where I am trying to debug the issue. Only the hardcoded 'li' works all the ".Render" entries silently render as blank. And even though no "Bogus.html" view exists anywhere, no error or warning is displayed.

        {{ range first 10 .Data.Pages }}
      <li><span><a href="{{ .Permalink }}">{{ .Title }}</a><time class="pull-right post-list">{{ .Date.Format "Mon, Jan 2, 2006" }}</h4></time></span></span></li>
            {{ .Render "Bogus" }}
            {{ .Render "li" }}
            {{ .Render "summary" }}
        {{ end }}

I checked the sample themes, but I notice neither of them uses views with ".Render" any more.

I tried 'hugo check' but it didn't display any warning either.

@spf13
Owner

Is your source somewhere I can see it to help debug?

@whereisaaron

Thanks for you interest @spf13, have emailed you my source separately.

@PhilG

+1 same problem. Finally got most of my stuff to work, now the homepage and lists won't render anything.

@spf13
Owner

@whereisaaron

I was able to reproduce this. I believe the problem is that you aren't telling hugo which theme to use.

You can do this via the command line hugo server -t THEMENAME or via the config file using the theme keyword.

I was able to render your site fine with hugo server -t geekblog. It's a good looking site. Excited to see it live.

If you aren't intending to publish the theme as a theme for others to use, then it's best to just place the files in $SOURCE/layout, that's the point of the $SOURCE/layout directory (as well as give you a place to customize your downloaded theme).

Please confirm and close.

@spf13 spf13 added the wontfix label
@whereisaaron

Hi @spf13, no that is not the issue; I always specify the theme with --theme="geekblog"

I use a build script that specifies the theme and outputs to a new and empty temporary folder each time (I do this rather than --watch because hugo doesn't delete orphaned files).

Since I have no 'layouts' folder, if I didn't specify the theme I get no 'index.html' generated at all.

I re-tested that now. With 0.11 and no theme specified I get no index.html. With -t geekblog or --theme="geekblog" or theme: geekblog in the config I get an index.html but the views all come out blank and there is no error or warning for bogus views e.g. {{ .Render "DoesNotExist" }}

With 0.11 and '-t geekblog' and my source, do the views render for you and you get an error for the bogus view that doesn't exist?

Thanks for the note about '/layouts'. I am using a theme to ensure I use good separation of theme and content. Plus, when I am happy with the theme I'll be able to share it easily. I will use my own '/layouts' for anything I can't separate or that is specific to my website/content.

@spf13
Owner

Thanks for confirming. I think I know what the issue is then.

@whereisaaron

Great @spf13, thank you for taking another look. I think the views are a good feature that I'll use a lot.

@spf13 spf13 added bug and removed wontfix labels
@spf13 spf13 closed this in 3a7e140
@spf13
Owner

@whereisaaron Please confirm this fixes the issue.

@whereisaaron

Yay! Views are back. After updating to latest code, and without changing my source the various views in my theme started rendering. Thanks for the fix @spf13.

I still get no warning or errors for views than don't exist. E.g. {{ .Render "SomethingThatDefinitelyDoesNotExist" }} still silently fails and renders nothing.

I am not sure what your philosophy on errors is? In my view not generating a warning or error for this is a bug. Shall I report that seperately, or do you see this behaviour as by design?

@spf13
Owner

I agree and committed a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.