You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see the code at the link below controls which categories' posts show up on the main page. However, I have two more categories (monthly roundup of links) that needs to display posts on the front page. How can I add support for categories other than "blog"?
@nishanths I figured this out, here's the index.html I am using on my site. I wasn't sure if you want this to be the default behavior for everyone but it made send for my site as I had other categories than just "blog". Hopefully it helps others looking to do this.
{{ partial "header.html" . }}
<section class="main">
<div class="container">
<div class="content">
{{ if .Content }}
<div class="markdown">
{{ .Content }}
</div>
{{ end }}
<!--{{ $totalpostscount := len (where .Data.Pages "Section" "blog") }}-->
{{ $totalpostscount := len (.Data.Pages) }}
{{ $latestpostscount := .Site.Params.latestpostscount | default $totalpostscount }}
{{ if gt $latestpostscount 0 }}
<div class="page-heading">{{ i18n "latestPosts" }}</div>
<ul>
{{ range (first $latestpostscount ( .Data.Pages.ByPublishDate.Reverse )) }}
{{ partial "li.html" . }}
{{ end }}
{{ if gt $totalpostscount $latestpostscount }}
{{ range where .Site.Menus.main "Identifier" "blog" }}
<li class="post-item no-bullet">
<a id="see-more" {{ printf "href=%q " .URL | safeHTMLAttr }}><span>See more…</span></a>
</li>
{{ end }}
{{ end }}
</ul>
</div>
{{ end }}
</div>
</section>
{{ partial "footer.html" . }}
I see the code at the link below controls which categories' posts show up on the main page. However, I have two more categories (monthly roundup of links) that needs to display posts on the front page. How can I add support for categories other than "blog"?
https://raw.githubusercontent.com/nishanths/cocoa-hugo-theme/master/layouts/index.html
The text was updated successfully, but these errors were encountered: