Hugo-theme-zzo: Top posts in sidebar

Created on 18 Feb 2020  路  16Comments  路  Source: zzossig/hugo-theme-zzo

Another idea (lurked in WordPress) came to my mind. A list of "top posts".

I could be a separate (optional, probably disabled by default) section in the sidebar, displayed probably between Posts and Tags. It would be powered by the weight mechanism added to particular posts (added and updated occasionally by hand, based on number of hits or whatever else) . While the same weight value (or lack of) for 2 or more posts they should be sorted by date descending.
It would be required to change the "Posts" header to "Recent Posts" and to add "Top Posts" (probably using Title from _index.md for the "Posts" name).

WDYT?

Most helpful comment

It's good information! Thanks

All 16 comments

It can be easily implemented using weight

---
title:
...
weight: 1
---

If you need this feature, I will add it.

It would be required to change the "Posts" header to "Recent Posts" and to add "Top Posts"

Yes, It should be changed manually

I would like to have it in my blog, so if it is not problematic to implement I will be happy to see it in Zzo :-).

It should be rather disabled by default to do not confuse existing users of your theme.

It can be done with .ByWeight keyword thanks for the Hugo
I'll commit code after I fixed another issue.

I committed the code!
You can set weight front-matter.
You should not set it 0

Oops, I misunderstood.
You mean display top post in the sidebar.
I鈥檒l do it tomarrow.
I鈥檓 going to sleep now

Yes, another lists in the sidebar :).

Sleep well ;-)

I added another list in the sidebar.
Follow the below steps.

  1. In your params.toml file,
...
enableSidebarPostsByOrder = true
  1. Add a new i18n item to your i18n file. e.g: root/i18n/en.toml
...
[posts-by-order]
other = "MY TOP POSTS"
  1. Add new front-matter order to your post md file.
---
title: 
...
order: 1
---

I've just tested it and it works great, thanks!

Two small suggestions:

  1. Maybe it would be good to add [posts-by-order] entry to the *.toml provided in your theme by default (to have it localized by default once enabled)?
  2. Having no pages in order found it the list header could be omitted (the same as for series, tags, ...).

Btw, having commits related to some GitHub issue you could put [#184] somewhere in the commit message. Thanks to that, it will be referenced in that issue (and there will be a link from the commit to it). It would be useful to people trying to get more information about the implementation of a given feature/bug fix.

I was tried to do that.
But it closes the issue automatically.
Maybe it could be a bug github desktop https://desktop.github.com/

Maybe you wrote fixes #XX. Just #XX shouldn't close it. I propose to try it again - maybe it was a bug then.

I'll try again here

#xx close issue automatically.
Maybe it's a bug or intended behavior.

Anyway, I did your suggestions https://github.com/zzossig/hugo-theme-zzo/issues/184#issuecomment-588179493

It is intended. You requested to close it:
image

See here for the supported keywords

if you don't want to close it just put #184 and there will be a reference.

It's good information! Thanks

You made my life easier by fixing this.

Was this page helpful?
0 / 5 - 0 ratings