-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: add dynamic copyright year handling #355
Conversation
✅ Deploy Preview for hugo-hextra ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi, thank you for the PR. I guess #239 is a relevant issue. I noticed that in the footer template hextra/layouts/partials/footer.html Line 32 in e4cdabf
the That means if we have a shortcode, e.g. {{- time.Now.Year -}} we could use this shortcode in copyright: "© {{`{{% year %}}`}} Your Project" similarly we can have a copyright: "© {{`{{% since %}}`}}-{{`{{% year %}}`}} Your Project" https://gohugo.io/functions/time/ has docs for the time functions If this works for you, we could use this PR to add better docs for this, and close #239 Footnotes |
Thank you for your advice! It is a great idea to utilize Hugo's features to implement this function. However, it may seem a little complex to add a specific shortcode to implement a simple function like this one. Actually I also referred another hugo theme, which inplement this feature in a more concise and standard manner. I apologize if my code is not standard enough cause I have little formal opportunities to learn frontended development knowledge in school. Therefore, I suppose you could leave this pull request open for a more refined implementation. Nonetheless, I appreciate your thorough review. |
My intention was to let users easily tweak the copyright notice to their liking, without being stuck to the predefined Regarding the standard format, I'm still unsure about it. First, users are able to hardcode the years under copyright: "© 2023-2024 YOUR PROJECT" This way, they don't have to change the start year, and updating the current year is just a once-a-year thing. And if users are asking dynamically generated current year, they can do so via the the utility copyright: "© 2023-{{`{{% year %}}`}} YOUR PROJECT" From my point of view, this is slightly more easier than modifying the
no worries at all. this is a great discussion! |
Now I understand you. It does make it easier for user if they could simply edit in i18n.yaml. I will try to implement this in the coming days. |
I like this idea, I'm not sure what the best solution is, though (I'm also not a Hugo pro). From a user perspective, it would probably be most intuitive to only edit copyright: "© 2023–{{ time.Now.Year }} Your Project" |
unfortunately afaik it's not possible to use hugo template functions in Markdown content |
One of our organization member finds that the copyright year of both our website and Hextra doc is still "2023" yet. Hence I make some changes to theme to fix this.
This PR implements dynamic handling of the copyright year in the footer template. It fetches the beginning year from the configuration file(config.yaml) and dynamically updates the copyright text based on the current year.
The convention is referred from Copyrightlaws.com. Where it mentions that:
Additionally, I also modify the exampleSite as well as i18n files to adapt to changes of this new feature. Let me know if I need more work on it. All code has been tested carefully.