I want to list realted posts in the sidebar by category, by default it picks up tags. But I want categories.
hi, you give us too less to help. any repository t look at?
tags and categories are both taxonomies. goto the sidebar template and replace tags with categories
When I change
{{ $related := .Site.RegularPages.RelatedIndices . “tags” “date” }}
to {{ $related := .Site.RegularPages.RelatedIndices . “categories” “date” }}
It returns an error.
Error: Error building site: failed to render pages: render of “page” failed: execute of template failed: template: _default/single.html:6:3: executing “_default/single.html” at <partial “sidebar” .>: error calling partial: “\layouts\partials\sidebar.html:3:28”: execute of template failed: template: partials/sidebar.html:3:28: executing “partials/sidebar.html” at <.Site.RegularPages.RelatedIndices>: error calling RelatedIndices: index “categories” not found
do you have categories activated in your config?
[taxonomies]
tag = "tags"
category = "categories"
yes activated
do you have a repository for more help?
I can only guess what happens
https://github.com/yousafblogger/thetryten That’s the repository
OK, will look later on it
If you use the RelatedIndices …
put this in your config (tags seems defaulted???)
[related]
toLower = false
[[related.indices]]
name = "categories"
weight = 100
Thank You! Done
There’s another problem. please check https://netlify2-theme.netlify.app/
one post is showing realted posts while the other doesn’t. How can I fix that?
Sorry, I don’t use netlify. Search in this forum for netlify problems.
That’s Hugo Sir, I uploaded it on netlify to show you the problem.
That’s the repository, help me fix it. One Post is showing related post, but the other doesn’t
The related content indexing is not related to taxonomies, see:
You need to define an index for the categories
front matter keyword.
config.toml
Change this:
[related]
includeNewer = false
threshold = 80
toLower = false
[[related.indices]]
name = "categories"
weight = 100
includeNewer = true
To this:
[related]
includeNewer = true
threshold = 80
toLower = false
[[related.indices]]
name = "categories"
weight = 100
Thank You!
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.