Skip to content

Add options to hide list dates #115

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

Merged
merged 10 commits into from
Jul 5, 2025
Merged

Conversation

crnh
Copy link
Contributor

@crnh crnh commented Apr 7, 2025

In some cases, it can be useful to hide the post dates in post lists. This PR adds two configuration options to hide dates:

  • showDate on single pages to show or hide the publication date on single pages;
  • showListDate on list pages to show or hide the publication date on list pages.

Both parameters default to true. I chose to configure the date display behaviour for collections on the list page; this may lead to edge cases when nested collections are used, but these can be mitigated by manually specifying the date display behavior on the list pages for nested collections as well. I don't expect nested collections to be used that often.
An alternative implementation could use a parameter on the list (or home) page which is then passed to the post-entry partial. Let me know if you prefer that over the current solution.

I also updated the features section of the wiki, as I think hiding dates on the features page would make sense. However, as only the content of the wiki is available in this repository, I cannot build the wiki to check what it looks like. Please let me know if the wiki still builds after these changes.

@tomfran
Copy link
Owner

tomfran commented Apr 19, 2025

Sorry for the late reply.

showDate on single pages to show or hide the publication date on single pages;

This is not needed, if you don't include the date in your page, it's not added. (To be fair, you also need to remove read time, otherwise you see something like · 12 min read.

But I guess not having a date has some implications, like page ordering.


showListDate on list pages to show or hide the publication date on list pages.

This could be a nice idea, where would someone need to specify this parameter? The wiki you wrote hints at putting it in the hugo.toml, but this would be a parameter in the collection itself, so _index.html under the collection folder right?


I also updated the features section of the wiki, as I think hiding dates on the features page would make sense.

Please don't do it, the idea is to showcase how a website would normally (assuming most people keep dates on) look.

@crnh
Copy link
Contributor Author

crnh commented Apr 19, 2025

This is not needed, if you don't include the date in your page, it's not added. (To be fair, you also need to remove read time, otherwise you see something like · 12 min read.

Okay, I can update the templates to use the date parameter then. The current implementation already removes the dot before the reading time if the date is not shown.

But I guess not having a date has some implications, like page ordering.

Hugo has a weight parameter than can be used to order pages in collections.

The wiki you wrote hints at putting it in the hugo.toml, but this would be a parameter in the collection itself

In that case the wiki is ambiguous, as I interpreted the Collections parameters as parameters that should be added to collection (list) pages, so that is why I put it there. Why would you prefer global collection options in hugo.toml over collection level parameters? With Hugo's cascade feature it would still be possible to specify these options in hugo.toml, but with much more fine grained control.

Please let me know where you want to have this parameter documented if the Collections page is not the right place.

Please don't do it, the idea is to showcase how a website would normally (assuming most people keep dates on) look.

Sure, I'll revert those changes.

@crnh
Copy link
Contributor Author

crnh commented May 7, 2025

Hi @tomfran,

I would still like to complete this contribution, but I cannot do that without an answer to my previous question. Could you please let me know where you want to have the showListDate parameter documented if the Collections page is not the right place?

@tomfran
Copy link
Owner

tomfran commented May 10, 2025

Sorry for the late reply.

In that case the wiki is ambiguous, as I interpreted the Collections parameters as parameters that should be added to collection (list) pages, so that is why I put it there. Why would you prefer global collection options in hugo.toml over collection level parameters? With Hugo's cascade feature it would still be possible to specify these options in hugo.toml, but with much more fine grained control.

Honestly when developing the theme I did not researched heavily in what's was possible, so global collection parameters were designed. I believe it prevents inconsistencies, and also is a fast and easy way to control everything in one place.

With Hugo's cascade feature it would still be possible to specify these options in hugo.toml, but with much more fine grained control.

Does this mean that if I set, for example, the listDateFormat parameter in a collection's _index.html file, I can override the global one set in hugo.toml?

If this is the case, I would simply add your parameter in a new section under collections. We can also add a preamble in the page mentioning that parameters can be overridden for a single collection by adding a _index.html file.

@crnh
Copy link
Contributor Author

crnh commented May 24, 2025

Does this mean that if I set, for example, the listDateFormat parameter in a collection's _index.html file, I can override the global one set in hugo.toml?

Yes, it will override the global setting for that collection, but cascading does more than that: https://gohugo.io/configuration/cascade/
In short, you can apply different settings to different collections from your global configuration. This means you can implement parameters at a page or collection level and still set them from your global configuration.

The following configuration in hugo.toml would change the list date format for a collection named publications, and hide dates on the collection page (I must admit combining these two settings is pretty useless...):

[cascade.params]
    listDateFormat = 'Jan 2006'
    showListDate = false
  [cascade.target]
    path = '{/publications,/publications/**}'

@crnh
Copy link
Contributor Author

crnh commented May 24, 2025

@tomfran I removed the showDate parameter and undid most changes to the wiki. I also updated the _defaults/single.html layout so it only displays the dot before the reading time if the post date is shown.

@tomfran
Copy link
Owner

tomfran commented Jun 2, 2025

Thank you! I haven’t forgotten about this, I just haven’t had much time lately. I’ll take a look soon. :)

@tomfran tomfran merged commit 8eb4770 into tomfran:main Jul 5, 2025
Geoc2022 added a commit to Geoc2022/typo that referenced this pull request Jul 5, 2025
Add options to hide list dates (tomfran#115)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants