Creating a website with Jekyll often involves adding a copyright footer that automatically updates each year. This ensures your site always displays the current year without manual updates, making maintenance easier and your site look professional.

Why Use a Dynamic Year in Your Footer?

Manually updating the copyright year each year can be tedious and error-prone. By using a dynamic approach, your footer will always show the correct year, saving time and ensuring accuracy. This is especially useful for websites that are updated frequently or have long-term maintenance plans.

Implementing a Dynamic Year in Jekyll

Jekyll uses the Liquid templating language, which allows you to insert dynamic content easily. To add a dynamic year, you need to modify your footer layout or include file with a simple Liquid expression.

Step-by-Step Guide

  • Open your Jekyll site's footer include file, typically located at _includes/footer.html.
  • Find the section where you have your copyright text.
  • Replace the static year with the following Liquid code: {{ 'now' | date: '%Y' }}.
  • Save the file and rebuild your site.

For example, your footer might look like this after editing:

<footer> © {{ 'now' | date: '%Y' }} Your Company. All rights reserved. </footer>

Benefits of Using Liquid for Dynamic Content

Using Liquid expressions like {{ 'now' | date: '%Y' }} makes your Jekyll site more flexible. It allows you to include other dynamic data, such as the current date, time, or custom variables, which can enhance your site's functionality and professionalism.

Conclusion

Adding a dynamic year to your Jekyll footer is a simple yet effective way to keep your website current. By editing your include files with Liquid code, you ensure your site always displays the correct copyright year, reducing manual updates and maintaining a polished appearance.