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

Ability to show tags on home page #880

Open
ottok opened this issue Oct 3, 2023 · 13 comments
Open

Ability to show tags on home page #880

ottok opened this issue Oct 3, 2023 · 13 comments
Labels
feature New feature or request

Comments

@ottok
Copy link

ottok commented Oct 3, 2023

Feature request

I like my new theme a lot, but there is one small thing that I miss from my old blog theme: showing tags on the home page.

For example:
image

Compare the Stack now used on my blog:
image

Current state

On the demo page we can see that categories are shown with colorful labels:
image

Inside posts the tags are shown at the end of the post:
image

Potential solutions

One solution could be to have the same tags in posts on the home page, but the labels seem a bit too big:
image

Another would be to have a simple line separated by commas:
image

@nishitxmehta
Copy link

Hi @ottok, can you please assign this task to me? I can do this for you!

@ottok
Copy link
Author

ottok commented Oct 4, 2023

Cool, thanks for volunteering @nishitxmehta! I don't have permissions to 'assign' any tasks, Jimmy can decide to do so when he wakes up.

Even without being assigned, you @nishitxmehta can draft a PR with your suggestion on what you think is the best design, or just post a screenshot here and ask for comments?

@nishitxmehta
Copy link

okay, thanks @ottok

@ottok
Copy link
Author

ottok commented Oct 6, 2023

Any design ideas/suggestions so far @nishitxmehta?

@nishitxmehta
Copy link

@ottok, I'll get back to you shortly!

@nishitxmehta
Copy link

Demo Design 🎨

I think we can go with this design of tags as shown below:

272389581-3e494684-a7f5-46fa-b6eb-4e66a1f25e33

Because the above design resembles with your old blog theme which you are expecting.

Old Blog Theme Design

272389581-3e494684-a7f5-46fa-b6eb-4e66a1f25e33

Do let me know if it suits you, I can start working on it!

@ottok
Copy link
Author

ottok commented Oct 6, 2023

No - I don't think my suggestion above is good. If it was, I would have already implemented it in code instead of leaving it as a mockup. Also, you should not do something because it suits me. This is open source - you should do what you feel inspired to do, or what you think makes the theme better for everyone.

@nishitxmehta
Copy link

I got your point @ottok!
Thanks for that suggestion by the way, I'll definitely share some designs with you shortly.

@CaiJimmy
Copy link
Owner

CaiJimmy commented Oct 7, 2023

Sorry for the late reply 🙏.

I suggest to add a configuration that allows to customize the displayed taxonomy. So instead of categories (currently hardcoded), users can change it to another taxonomy, like tags in this case.

Related code:

{{ if .Params.categories }}
<header class="article-category">
{{ range (.GetTerms "categories") }}
<a href="{{ .RelPermalink }}" {{ with .Params.style }}style="background-color: {{ .background }}; color: {{ .color }};"{{ end }}>
{{ .LinkTitle }}
</a>
{{ end }}
</header>
{{ end }}

If we choose this solution, we'll also need to make the footer taxonomy customizable (currently tags is hardcoded).

@ottok
Copy link
Author

ottok commented Oct 7, 2023

In most blogging systems (e.g. WordPress) the 'category' and 'tag' exists in parallel and are not necessarily a choice of either/or. In my experience blog posts typically have only one category, but may have multiple tags. For example a lifestyle blog could have post about a trip to Hawaii in category 'Travel' but with tags 'Hawaii, Beach destinations, Warm places'.

The current design of a large label above the post title suits category-type of use well, since there will be max 1-2 labels per post. If the same large labels above the post is used for 3-5 tags it gets visually too busy.

However looking at https://gohugo.io/content-management/taxonomies/ there is no prescription about category/tag usage in Hugo, and one can even have any arbitrary name on the taxonomy, so this is eventually mostly just a matter of taste/preferrence.

@CaiJimmy CaiJimmy added the feature New feature or request label Oct 9, 2023
@chuxinyuan
Copy link

Demo Design 🎨

I think we can go with this design of tags as shown below:

272389581-3e494684-a7f5-46fa-b6eb-4e66a1f25e33

This design is very comfortable with the blog theme, can you share your code? Thanks!

@AOM98
Copy link

AOM98 commented Nov 25, 2023

I got your point @ottok! Thanks for that suggestion by the way, I'll definitely share some designs with you shortly.

Hello @nishitxmehta , just checking in to see where you stand with this feature 😄

@ottok
Copy link
Author

ottok commented Feb 22, 2024

My screenshot above was just a manually made version directly with browser tools. I took a stab at doing it in the theme code by adding tags to the archive page:

--- a/layouts/partials/article-list/compact.html
+++ b/layouts/partials/article-list/compact.html
@@ -4,7 +4,14 @@
             <h2 class="article-title">
                 {{- .Title -}}
             </h2>
+            <footer class="article-translations">
+                {{ partial "helper/icon" "tag" }}
+                {{ range (.GetTerms "tags") }}
+                    {{ .LinkTitle }}
+                {{ end }}
+            </footer>
             <footer class="article-time">
+                {{ partial "helper/icon" "clock" }}
                 <time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'>
                     {{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}

But this renders quite badly, as I did not figure out a way to add commas between tags, nor how to limit that it shows max 5 tags etc.. so end result is a bit ugly:

image

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

No branches or pull requests

5 participants