UtkarshVerma / hugo-dream-plus

:rainbow: An upgraded version of the Hugo "Dream" theme with tons of new features.
http://dream-plus-posts.netlify.com
MIT License
68 stars 66 forks source link

Post tags list is listing all tags #52

Closed ShaunaGordon closed 5 years ago

ShaunaGordon commented 5 years ago

Describe the bug
The tag list on the bottom of individual posts is listing all of the site's tags, instead of just the tags for that post.

To Reproduce

  1. Create multiple posts with different tags (so that any given post only has some of the tags).
  2. Build.
  3. View a post.

See also: the demo site

Expected behavior
A post should only have its own tags in its footer.

Screenshots
GCI page source tags: GCI page source tags

GCI page rendered tags GCI page rendered tags

Additional context
A little experimenting shows that changing, in tags.html:

{{ range $name, $taxonomy := $.Site.Taxonomies.tags }}

to

{{ range $name := .Params.tags }}

appears to result in the expected behavior (however, I don't know enough about Hugo to know whether this has any side effects).

Hugo version
Stable 0.51

UtkarshVerma commented 5 years ago

@ShaunaGordon Thanks for reporting this bug. I'll be fixing it within a couple of days. Tags used to work fine in older versions of Hugo, but I think they made some changes recently.

UtkarshVerma commented 5 years ago

Tags used to work fine in older versions of Hugo, but I think they made some changes recently.

That wasn't the case, it turns out that I had made a logical error in the code while generalizing the usage of tags in the theme through tags.html partial. It's fixed now, the fix was similar to what you had proposed, except conditional blocks had to be used for differentiating the partial usage for posts from other places(author card etc.)

Closing this issue for now, if you still feel that something's lacking, feel free to reopen it.

ShaunaGordon commented 5 years ago

@UtkarshVerma are the tags on the author sidebar intended to reflect only the ones for the post when on a post, or should they display all of the tags like they do on the home page?

As it happened, I toyed with if .IsPage, too, to avoid multiple tag templates, but it results in the behavior now seen. I suspect another trigger is needed if the author panel should list everything (some sort of if .IsPage and not $authorPanel type structure, then pass in $authorPanel = true from the panel's code should work with minimal changes to all of the instances that call the tags partial, but I have no idea how to cleanly pull it off in Go's templating).

image

UtkarshVerma commented 5 years ago

@ShaunaGordon I had also stumbled upon this thought while I was fixing the bug, that is, should I display all the tags on the sidebar or not? When I did make it so that it displayed all the tags, it took too much space and looked bad, so I had to limit the sidebar tags to those of posts only. I still don't know which is better, all tags or only the post ones.
What thoughts do you have on this matter? Does it serve any purpose to display post tags(already shown at the page footer) separately in the sidebar?

UtkarshVerma commented 5 years ago

The fix has been pushed upstream.

ShaunaGordon commented 5 years ago

What thoughts do you have on this matter? Does it serve any purpose to display post tags(already shown at the page footer) separately in the sidebar?

It seems a bit odd, I think, to have just the post's tags on the sidebar, especially if the expectation is that all of the tags are present (which is set on the home page, where all of the tags are present in the sidebar). However, I do agree that it can get unruly on a blog with a lot of different tags.

Perhaps a slightly different approach would be useful? Maybe the top X tags (probably ~10, but maybe be configurable?), based on something like number of posts per tag or most recently-updated would be a better solution for the sidebar list? A tag cloud is another common option, but I'm not sure it fits the aesthetics of this particular theme (at least not without some larger changes to the tag design, and almost certainly not without making a separate partial).

The more I think about it, the more I kind of like the "newest" or "most-used" subset idea.

UtkarshVerma commented 5 years ago

@ShaunaGordon Displaying only the top 10 tags seems doable, I'll try to implement this feature later when I have the time. Thanks for the suggestion.

UtkarshVerma commented 5 years ago

@ShaunaGordon The feature has now been implemented! Now only top 8 tags are displayed by default which can be modified to the user's choice through tagLimit variable under [params.tags].