-
-
Notifications
You must be signed in to change notification settings - Fork 574
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
Fix index.html for Hugo 0.57.0 #227
Conversation
In Hugo 0.57.0, a change was made that caused this theme to incorrectly render the recent posts. More information can be found [here](gohugoio/hugoThemes#682). This edit should fix that error. It has been tested on a live site and it works.
@@ -16,7 +16,7 @@ <h2>{{ .Site.Params.recent_posts.title }}</h2> | |||
|
|||
<div class="row"> | |||
|
|||
{{ $posts := .Paginate (where .Data.Pages "Type" "blog") }} | |||
{{ $posts := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be .Site.RegularPages
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
site
is a new global variable introduced in Hugo 0.53:
Global site and hugo var: Two new global variables in
site
andhugo
.hugo
gives you version info etc. ({{ hugo.Version }}
,{{ hugo.Environment }}
), but the site is probably more useful, as it allows you to access the current site’s variables (e.g.{{ site.RegularPages }}
) without any context (or “.”).
So site.RegularPages
and .Site.RegularPages
should be the same. I don't know when and why to prefer which one, though...
Here's the corresponding Hugo issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why mainSection and not blog only ({{ $posts := .Paginate (where .Site.RegularPages "Type" "blog") }}
) to have same functionality ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why mainSection and not blog only ({{ $posts := .Paginate (where .Site.RegularPages "Type" "blog") }}) to have same functionality ?
By using "blog"
instead of site.Params.mainSections
you actually hardcode the content type of blog posts to "blog"
. This is bad for users who want to customize the content type name of their blog posts (e.g. one might prefer "posts"
, "articles"
or whatever).
When using site.Params.mainSections
the user can simply define what content type(s) should be treated as "articles" and therefore show under recent posts by setting the key params.mainSections
in config.toml
(the default should of course be params.mainSections = "blog"
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok you convince me, but this PR should update:
- example config.toml
- Readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convince too with updated config.toml which wasn't mentioned at the beginning
@ryanfox1985 Would be great to get this merged (with my comments) as the template is currently broken on hugo 0.58+. |
closed by #233 |
@Leoj03 please can you update your PR with:
Thanks! |
#228 already includes this change. So if it is merged before, you can just rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Together with #228 this is fine.
In Hugo 0.57.0, a change was made that caused this theme to incorrectly render the recent posts. More information can be found here. This edit should fix that error. It has been tested on a live site and it works.