nikola icon indicating copy to clipboard operation
nikola copied to clipboard

Show count against tag/category

Open ChillarAnand opened this issue 2 years ago • 5 comments

Requested Feature: (short description) Screenshot 2022-05-14 at 13 30 21

In tags page, currently only tags/categories are shown.

Does this feature affect backwards compatibility? If yes, in what way?

No

Do you want to contribute this yourself as a pull request? (don’t worry about it if you don’t want to/can’t — someone else can take care of it)

  • [x] Yes, I don’t have code ready yet (that’s okay!)

Rationale and full description: (why should it be added to Nikola?)

Screenshot 2022-05-14 at 13 26 49

Most of the blogging platforms(like blogger, wordpress) have this feature by default. Having count against tag/cateogry gives a glimpse on how many items are present against each tag.

There are nikola plugins that do generate tag count, tag cloud etc. Some of them just generate json files. Users have to setup custom code for front end.

Since nikola already generates taxanomies, showing count along with it will provide better insights by default.

ChillarAnand avatar May 14 '22 08:05 ChillarAnand

I love this idea, but I wonder about how the layout would need to change in order to display this information in a mobile friendly way that makes sense.

The example you show uses a fully vertical layout, and I rather like the current horizontal list layout the default Nikola theme currently has.

feoh avatar May 21 '22 02:05 feoh

The main problem with showing numbers is that it requires all pages that include them to be regenerated when any of these counts change. If you have such information in a sidebar, it means that every single page has to be generated when adding a blog post or something, which goes against Nikola's philosophy of incremental builds. But including them in standalone pages (like tags/categories page) should not be a problem.

There are nikola plugins that do generate tag count, tag cloud etc. Some of them just generate json files. Users have to setup custom code for front end.

Or you have a second pass. I'm using that with my sidebar plugin (https://github.com/getnikola/plugins/tree/master/v7/sidebar) and then do a second pass with https://github.com/felixfontein/filetreesubs/ to have this HTML fragment included into every page without forcing Nikola to rebuild all pages. (The substitution step is pretty fast, while a Nikola full rebuild for my blog takes quite a long time.) But this is not trivial to set up...

felixfontein avatar May 21 '22 08:05 felixfontein

@feoh A layout like this could work:

image

(Although I think our tags/categories page looks kinda ugly and unreadable if there are lots of tags and the screen is wide.)

Kwpolska avatar May 21 '22 09:05 Kwpolska

I didn't get a chance to work on this. If someone is willing to take it up, please go ahead.

ChillarAnand avatar Oct 01 '22 14:10 ChillarAnand

If you have such information in a sidebar, it means that every single page has to be generated when adding a blog post or something, which goes against Nikola's philosophy of incremental builds.

Movable Type provides a nice way of doing this. It allows the sidebar to be defined in a cached template, that is rendered only once, then included in any other site template that needs it, either statically (the once-rendered cached content) or using an Apache or a PHP include server-side. Ways of caching and including are configured as metadata of the template. MT even lets you tell it when to invalidate that cache, for example if there has been a change in the categories, or a new categorised entry added then regenerate this particular template. This way it will only regenerate the minimum amount of files. Using the web server to perform the inclusion dynamically allows to just regenerate a single file and enjoy instant update where regenerating whole lists of pages would be prohibitive.

padawan avatar Feb 11 '23 20:02 padawan