CaiJimmy / hugo-theme-stack

Card-style Hugo theme designed for bloggers
https://stack.jimmycai.com
GNU General Public License v3.0
4.83k stars 1.55k forks source link

Ability to show tags on home page #880

Open ottok opened 11 months ago

ottok commented 11 months ago

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 commented 11 months ago

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

ottok commented 11 months ago

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 commented 11 months ago

okay, thanks @ottok

ottok commented 11 months ago

Any design ideas/suggestions so far @nishitxmehta?

nishitxmehta commented 11 months ago

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

nishitxmehta commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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

CaiJimmy commented 11 months ago

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: https://github.com/CaiJimmy/hugo-theme-stack/blob/bda734fb234df2d1e70ec9c358dbdd77905e3f20/layouts/partials/article/components/details.html#L2-L10

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

ottok commented 11 months ago

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.

chuxinyuan commented 10 months ago

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 commented 9 months ago

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 commented 6 months ago

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