hugo-tailwind-journal
hugo-tailwind-journal copied to clipboard
Tags not working?
First, thanks for this template, it's very pretty! I wanted to ask if the tags are working properly. My expectation was that when you select one from a post, it'll show you all other posts that share that tag. This behavior doesn't seem to be the case in the demo site.
I was playing around with it a bit and renaming layouts/taxonomy/terms.html
to layouts/taxonomy/tag.html
magically gave me the behavior I expected. You can compare the demo with my personal site: https://blog.tylerlittlefield.com.
Initial change here: https://github.com/tyluRp/tylurp/commit/c50d41bb456ea686e3e7e72496029d5fc0c1f9b6 Second, formatting change here (list instead of buttons): https://github.com/tyluRp/tylurp/commit/e4a90c83807b2e69161353a886ef9f42db31cffb
Thanks! @tyluRp, I've adopted your solution, it works!
I renamed to layouts/taxonomy/terms.html
to layouts/taxonomy/tag.html
But according to your changes, https://github.com/tyluRp/tylurp/commit/e4a90c83807b2e69161353a886ef9f42db31cffb#diff-c17e178ad07a2a039c99d475bf59e2efad0b8c36fa1b1738966eb6ab5ac71812
I don't understand your last changeset, I've left a comment.
Hi @leiless, glad it's working for you. To be honest, I can't remember if I made that change directly or it happened automagically when compiling the site at one point. Sorry I can't be much help here!
@tyluRp Also willing to thank you for giving these directions, i also followed them and it allowed me to not spend time about analyzing this.
So in fact, i think the best is to have a few additional files in order to have everything working (categories, tags, pages listing all tags or all categories, and page filtering all the posts matching one tag or one category, by using the exact same layout than the main page).
So you should have in the end :
-
taxonomy/terms.html
: as commited in this github repo, and this is what will print a "cloud of tags" (or categories), when accessing the URL/tags/
or/categories/
- when you click on any of them, the next file "tag.html" is used. -
taxonomy/tag.html
: new file to be created and that will be very simple / very close to the main index page : this will list all the posts matching the current selected tag (so it will be triggered when using the URL/tags/<tag_name>
)
{{ define "content" }}
<section class="mb-24">
{{ range .Data.Pages.GroupByDate "2006" -}}
{{ partial "posts.html" . }}
{{- end }}
</section>
{{ end }}
-
taxonomy/category.html
: same than tags ! (exact same HTML content, but will be triggered through/categories/<category_name>
(if you are willing to use categories) (and of course in this case, you need to change the main "post" layout (single.html
) in order to also display in some way the categories)
And i would then just suggest to change the _default/baseof.html
page, where the <h1>Title</h1>
is, in order to display : the regular Title for homepage (as before), but "tag #
{{ block "heading" . }}
<div>
{{ partial "back-home.html" . }}
<h1 class="text-4xl font-bold">
{{ if or
(eq .Kind "term")
(eq .Kind "category")
}}
{{ .Data.Singular }} #{{ .Title }}
{{ else }}
{{ .Title }}
{{ end }}
</h1>
</div>
{{ end }}
note : i've answered about the {{-
extra dashes (no need to worry about this, it doesn't change anything)