Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix index.html for Hugo 0.57.0 #227

Merged
merged 3 commits into from
Oct 29, 2019
Merged

Fix index.html for Hugo 0.57.0 #227

merged 3 commits into from
Oct 29, 2019

Conversation

Leoj03
Copy link
Contributor

@Leoj03 Leoj03 commented Sep 20, 2019

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.

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) }}
Copy link
Contributor

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?

Copy link
Collaborator

@salim-b salim-b Oct 10, 2019

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 and hugo. 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.

Copy link

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 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @aperrad #233

Copy link
Collaborator

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").

Copy link
Contributor

@ryanfox1985 ryanfox1985 Oct 25, 2019

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:

Copy link

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

@1wilkens
Copy link
Contributor

1wilkens commented Oct 10, 2019

@ryanfox1985 Would be great to get this merged (with my comments) as the template is currently broken on hugo 0.58+.

@ryanfox1985
Copy link
Contributor

closed by #233

@ryanfox1985
Copy link
Contributor

ryanfox1985 commented Oct 25, 2019

@Leoj03 please can you update your PR with:

  • example config.toml in order to have the current behaviour (showing posts from blogs)
  • Readme explaining the usage.

Thanks!

@1wilkens
Copy link
Contributor

@Leoj03 please can you update your PR with:

#228 already includes this change. So if it is merged before, you can just rebase.

Copy link
Collaborator

@salim-b salim-b left a 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.

@ryanfox1985 ryanfox1985 merged commit 25bbf43 into devcows:master Oct 29, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants