As an experienced website operations expert, I am well aware of the importance of the details of website content, especially the minor details like the copyright year in the website footer, which not only concerns the professional image of the website but also indirectly affects the search engine's judgment of the "freshness" of the website content.It is naturally easy to achieve this in such an efficient and flexible content management system as AnQiCMS.Today, let's talk about how to automatically display the current year in the footer of a website, so that your website always remains 'youthful'!
AnQi CMS: Automatically update the copyright year at the footer of the website, say goodbye to the trouble of manual modification
During the operation of the website, many small and medium-sized enterprises or self-media operators often ignore a seemingly trivial detail that actually affects the professionalism and user experience of the website - the copyright year in the footer.If your website footer is still stuck in a few years ago, it not only makes visitors feel that the website lacks maintenance, but may also bring unnecessary trouble in some legal scenarios.Manually update once a year, although it is not frequent, it is also easy to forget, and it is undoubtedly repetitive work for multi-site managers.
The Anqi CMS offers a perfect solution with its simple and efficient architecture and powerful template features.It uses a syntax similar to the Django template engine, allowing you to easily convert technical information into practical display effects.
Learn about the template structure of AnQi CMS
To modify the website's footer, we first need to understand the template file organization of Anqi CMS. Typically, the template files of Anqi CMS are stored in/templatethe directory, and.htmlAs a file suffix. To improve the reusability of templates, common code segments such as headers (header) and footers (footer) are often extracted and placed/template/您的模板目录/belowbash.html(As a common skeleton) orpartial/For example, in the subdirectorypartial/footer.html. These files carry the common elements of the website, ensuring consistency of style across all pages.
Core tags:{% now %}power
The key to automatically updating the footer year in Anqi CMS lies in a very practical built-in tag -{% now %}. This tag is used to retrieve and display the current date and time, which allows us to accurately extract the current year.
{% now %}The use of labels is very intuitive, it requires a format string as a parameter, to tell the system how you want to display the current date and time. This format string follows the Go language's unique time formatting rules, with the most critical reference date being2006-01-02 15:04:05. You need to replace the corresponding part of this reference date with the output format you want. For example, if you want to display a four-digit year, the format string is"2006".
Step Details: Displaying the year dynamically in the footer
With an understanding of the template structure{% now %}Understand the tags, we can start to make changes.
Locate the footer template fileFirst, you need to log in to the AnQi CMS backend, navigate to the "Template Design" section, and then enter "Template Editing". Here, find the template directory you are currently using (for example
default)。In the template directory, look for the file namedbash.htmlor in thepartial/subdirectoryfooter.htmlOr other files that may contain footer copyright information.If you are unsure which file it is, try searching for keywords similar to "CopyrightModify the copyright year codeFind the code line in the footer file that contains the copyright year. It may look like this:
<p>Copyright © 2023 Your Company. All rights reserved.</p>Or
<p>© 2023 AnQiCMS</p>Now, we will replace the static year with a dynamic one.
{% now %}.Only show the current year:If you want to display only the current year, for example “© 2024”, you can modify it like this:“
<p>Copyright © {% now "2006" %} Your Company. All rights reserved.</p>Display the year range (for example “© 2020 - 2024”):If your website was established in 2020 and you want to display the range from the starting year to the current year, you can do it like this:
<p>Copyright © 2020 - {% now "2006" %} Your Company. All rights reserved.</p>Please replace
2020Replace it with the actual starting year of your website.
Save and view the effectAfter completing the code modification, save your template file.To ensure that the modification takes effect immediately, you may need to go back to the Anqi CMS backend and clear the system cache under the 'Update Cache' function.Then, refresh your website's front-end page, and you will find that the copyright year at the footer has been automatically updated to the current year!
By making such a simple modification, your website footer will automatically update every year, without manual intervention, thereby maintaining the accuracy of information and enhancing the professionalism of the website.This is a small but beautiful convenience brought by Anqi CMS for website operations.
Summary
With the help of Anqi CMS, making the copyright year of the website footer automatically update is a simple and practical operation. Just understand its template mechanism and apply it flexibly.{% now %}The label can permanently solve this detail problem.This not only makes your website look more professional, but also saves the trouble of manual modification every year, allowing you to focus more energy on real content creation and marketing strategies.
Frequently Asked Questions (FAQ)
Q1: How do I display a year range like “© 2020 - 2024”?
A1:Very simple. You just need to manually enter the starting year of the website, then use{% now "2006" %}Dynamically display the current year. For example, if your website was launched in 2020, you can write it like this in the footer template:© 2020 - {% now "2006" %} Your Company. All rights reserved.Thus, whenever a new year comes, the system will automatically replace the year '2006' with the latest year.
Q2:{% now "2006" %}What does the '2006' represent? Can I change it to display a different date format?
A2:Go language uses a specific reference date when formatting dates and times2006-01-02 15:04:05.999999999 -0700 MSTThis seemingly random date actually has special meanings for each number and character, corresponding to year, month, day, hour, minute, and second, etc. Therefore, you are in{% now %}The "2006" provided in the label tells the system that you want to extract and display the year part.
Of course, you can change it to display a different date format! For example:
- Display "2024-01-02":
{% now "2006-01-02" %} - Display "Jan 2, 2024":
{% now "Jan 2, 2006" %} - Display "01/02/2024":
{% now "01/02/2006" %}Only adjust the format string according to the reference date rule of the Go language.
Q3: What if my website has multiple footers or I can't find the footer file?
A3:In AnQi CMS, the common footer of the website is usually defined in the root directory of your current theme.bash.htmlIf your theme splits the footer, it may be located in the file.partial/footer.htmlor a similar path.
If you still can't locate:
- Check the "Template Design" menu:In the Anqi CMS backend, go to 'Template Design' -> 'Template Edit', select the currently active template, and then check the file list one by one, especially
bash.htmlorpartial/the files in the directory. - Search keywords:In the background "template editing", there is usually a search function, you can try searching for keywords such as "copyright", "copyright", "footer" to quickly locate the files containing the relevant code.
- Multiple template situations:If your website has enabled the independent template mode for PC and mobile end, then there may be respective footer files under each template directory, and you may need to modify them separately. Through these methods, you should be able to find and modify the correct footer template file.