ianrodrigues / hugo-tailwind-journal

A minimalist journal template for Hugo.
MIT License
42 stars 10 forks source link

Tags not working? #3

Open tylerlittlefield opened 4 years ago

tylerlittlefield commented 4 years ago

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

leiless commented 3 years ago

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.

tylerlittlefield commented 3 years ago

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!

SR-G commented 3 years ago

@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 :

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 #" when a tag is selected (it makes things much clearer when navigating)

                {{ 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)