Purpose
When I made some changes to my Gallery page today, I realised the copyright year does not display correctly, it is still displayed for the year 2023 instead of the year 2024.
The blog template engine is Hexo. When I navigate to the source code of this section, I understand why it was not displayed correctly.
The copyright year was displayed based on the year of the post-written year so of course it will not update automatically.
Fix
Instead of displaying the copyright year based on the post-written year, I want it could be updated automatically which is always keeping up to date.
It is an easy fix by adding a simple script within the copyright information and letting it retrieve the current year instead of the post-written year.
1 | <script>document.write(new Date().getFullYear())</script> |
Reference
About this Post
This post is written by Andy, licensed under CC BY-NC 4.0.