Skip to content
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

Listing content by Taxonomy doesn't work #272

Open
q5sys opened this issue May 8, 2020 · 13 comments
Open

Listing content by Taxonomy doesn't work #272

q5sys opened this issue May 8, 2020 · 13 comments

Comments

@q5sys
Copy link

q5sys commented May 8, 2020

Hoping you can point me in the right direction.
I've got Docsy installed and its working great.
I wanted to add tagging into it, so I've edited my config.toml to add

[taxonomies]
tags = "tags"

and I then removed disableKinds = ["taxonomy", "taxonomyTerm"]

Ive written my tags partial, and added the partial to content.html.
When I add the taxonomy to the front matter of a markdown file, the tags render properly.

However when I click one, I expect to get the list of all taxonomies in the typical way that Hugo does that, however all I ever get is a blank page.
I'm trying to track down what in Docsy would be causing this, and the only thing I can come up with is that list.html has been changed.
Would that be it, or is there something else in Docsy which would break Hugo from being able to display the list of taxonomies? From my understanding that's a built in feature of Hugo, and I've never had any problems using it before.
Thanks!

@LisaFC
Copy link
Collaborator

LisaFC commented May 12, 2020

Hmm, that's strange. It might need its own list.html layout to display the results. I'll take a look.

What version of Hugo are you using, as I think there's some newish Taxonomy stuff in recent versions.

@q5sys
Copy link
Author

q5sys commented May 12, 2020

I'm currently using 0.69 and I've tested on 0.66 and 0.68 with the same results. I have yet to try out the newer 0.70 from last week. I've got some time later this week to try a few other things, so I'll report back if I figure anything else out.

@q5sys
Copy link
Author

q5sys commented Jun 16, 2020

Sorry for the delay in responding, life has been busy.
I've finally gotten the time to test this the other day with the newest 0.72 extended release. but I'm still getting a blank page. I'm guessing it has to be something with the list.html file as mentioned before. At the bottom I'll append the list.html i've used before, but its not working with Docsy, it may be a simple issue, but i'm not seeing it.

Here's everything I've done with the default Docsy example site in this testing:

I edited config.toml and removed disableKinds = ["taxonomy", "taxonomyTerm"] and added:

[taxonomies]
products = "products"

I added {{ partial "article_meta.html" . }}
as line 2 of ./docsy/layouts/_default/content.html

created ./docsy/layouts/partials/article_meta.html

<header class="article-meta clearfix">
  {{ partial "article_tags.html" . }}
</header>

I created ./docsy/layouts/partials/article_tags.html

{{ if isset .Params "products" }}
{{ if not (eq (len .Params.products) 0) }}
<div class="article-products">
  <span></span>
  {{ range .Params.products }}
  <a class="article-products-link" href="{{ $.Site.BaseURL }}/products/{{ . | urlize }}">{{ . }}</a>
  {{ end }}
</div>
{{ end }}
{{ end }}

Then in an article I add something like products: ["k8s"] to the frontmatter.
When I run hugo, the tag shows up at the top of the article and it is clickable, if I click it I'm taking to the proper taxonomies page, but it will be blank. My expectation, and what I've gotten with other Hugo themes is that I get a list of all articles with that Taxonomy tag. However for a documentation site, Docsy is the best theme I've come across so Docsy is what I want to use.

My functioning list.html on other hugo sites:

{{ partial "head.html" . }}
<body>
  <header>
    {{ partial "header.html" . }}
  </header>
  <div id="container">
    <div id="main">
      {{ range .Data.Pages.GroupByDate "2006-01" }}
      <h2 id="{{ .Key }}">{{ .Key }}</h2>
      {{ range .Pages }}
      {{ partial "article.html" . }}
      {{ end }}
      {{ end }}
    </div>
    {{ partial "sidebar.html" . }}
  </div>
  <footer>{{ partial "footer.html" . }}</footer>
  {{ partial "after_footer.html" .}}
</body>
</html>

@nlundquist
Copy link

nlundquist commented Aug 5, 2020

This is due to Docsy not defining any appropriate template for a single taxonomy or a taxonomy listing, e.g of the templates listed at the following:
https://gohugo.io/templates/lookup-order/#examples-layout-lookup-for-taxonomy-pages

the only one defined by docsy is layouts/_default/list.html which is simply:

{{ define "main" }}
{{ with .Content }}
{{ . }}
{{ end }}
{{ end }}

Since taxonomy pages do not have defined .Content, they render blank.

Adding implementations of layouts/_default/tag.html & layouts/_default/tag.terms.html will result in better output.

@LisaFC
Copy link
Collaborator

LisaFC commented Aug 5, 2020

Ahhhh, thanks for that. I'll have a play around with adding those templates and see if I can get it working.

@q5sys
Copy link
Author

q5sys commented Aug 11, 2020

Interesting, none of the Hugo sites I've used before have a tag.html or tag.terms.html defined. Actually none of them have had anything special in any way that I can figure out which allows the taxonomies to work, but maybe I'm missing something obvious.
https://github.com/chipzoller/hugo-clarity
https://github.com/colorchestra/smol
https://github.com/huyb1991/hugo-lamp
https://github.com/coderzh/hugo-pacman-theme

@q5sys
Copy link
Author

q5sys commented Aug 13, 2020

Ok, so I managed to get this working, but right now its raw and ugly so it doesn't fit into the rest of the nice docsy themeing I'll work on cleaning it up and then file a PR. Or If I cant manage to get the themeing cleaned up, I'll just push it to a fork and let you pull what you need.

@b-jsshapiro
Copy link

I was planning to add this as well, so if you feel inclined to share your new template files I'd sure appreciate it.

@nlundquist: Does the list template get used for pages that generate subdirectory listings? I haven't been entirely happy with how that currently works in Docsy, but wasn't entirely sure which template to touch.

@q5sys
Copy link
Author

q5sys commented Oct 8, 2020

@b-jsshapiro hopefully I can get time this weekend to finish up the PR, then you can see exactly how I have the template set up.

@honzik20
Copy link

Ok, so I managed to get this working, but right now its raw and ugly so it doesn't fit into the rest of the nice docsy themeing I'll work on cleaning it up and then file a PR. Or If I cant manage to get the themeing cleaned up, I'll just push it to a fork and let you pull what you need.

@q5sys Can you tell me how you got it working? I'm still coming up with blank pages...

@q5sys
Copy link
Author

q5sys commented Dec 12, 2020

@honzik20 all my work is here: https://github.com/q5sys/docsy
As mentioned in the PR I'd like to set a config param that could be used with an if statement in toc.html, to avoid someone having to edit the files to enable the tag cloud but I havent worked that out yet.

@huehnerlady
Copy link
Contributor

Hi, I find this really interesting and would also like to use it. Is there any update on this? :)

@narrenfrei
Copy link
Contributor

Hi @huehnerlady, yes I've started a new PR #554 which is ready to merge (since about 5-6 hours). I'm only waiting for some feedback (#554 (comment)) and some issues with the google-cla bot have to been solved ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants