Need help getting widget to show category list count and labels (after I removed category prefix and added category pages)

Heres the scenario, Im using a hugo starter template, and decap cms for admin settings to write blog post ect. The template (geeky-hugo) Im using has a sidebar widget that display the number of post in each category. It also displays the category label on the posts image. Now the problem is my blog does not show the category count for any posts that I published using decap cms nor does it place labels any categories. I did make two major changes. First I removed the category prefix from the URL. And I added category pages to the template. Any help. I been working on this for months.

You should direct this question to the theme author on GitHub.

I edited the theme, it was working fine. However I need my blog url to render without the category prefix in the URL and I added category pages along with decap cms. I think the problem might be in the config.yml settings; The field is named Category in that setting however for my blogs and everything else its label Categories, on the left is a snapshot of the config.yml file and the right a index page for a category. :arrow_up:

We don’t have enough information to help you.

You are more likely to receive a prompt and accurate response if you post a link to the public repository for your project.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

1) You have page collisions. Run hugo with the --printPathWarnings flag for details. Fix it by removing the items indicated below:

config.toml

[taxonomies]
  tags = "tags"
  category = "categories"
  ecommerce = "ecommerce" # delete this
  entrepreneurship = "entrepreneurship" # delete this
  gig-economy = "gig economy" # delete this
  investing = "investing" # delete this
  monetizing = "monetizing" # delete this
  online-business = "online business" # delete this
  personal-finance = "personal finance" # delete this
  side-hustle = "side hustles" # delete this

2) In your content/categories/whatever/_index.md files, remove the url field. You’ve already taken care of that with the permalinks setting in your site configuration.

3) In your content/categories/whatever/_index.md files, remove the categories field. You apply a taxonomy term to content, not to the term’s list page.

4) In your blog content pages, sometimes you specify category instead of categories in front matter. Always use the plural.

5) In your blog content pages, each categories field must be an array. A few of the files have a scalar value, and you can’t range over that.

My goal was to remove the category prefix. Would this edit make the category prefix appear in the URL again?

In your local development environment, make the changes that I suggested, and then test.

So for the blog content pages that specify as categories; thats another issue I was trying to figure out. When I added decap CMS the label fields format was like so. When I tried to change to structure my post failed. But i when i edited the category prefix in config.yml to return as categories I couldn’t access my category pages. But i think with the updates you mentioned it will help so im gonna work on em now. Thanks for the help, Ill give you an update here shortly.

Yeah, this is wrong too:

 - {label: "Category", name: "category", ...

The name must be plural to match your taxonomy definition. And it should be a list (array) not a scalar.

See example.

That was it, thanks for the help!!! :+1: :+1:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.