#Hugo

How to Automatically Update the Footer Copyright Year in Hugo

Available for new projects • My templatesRefer them & earn up to $59

Author: Radu

Stunning Framer templates—fully customizable, built to impress, ready for you or your clients • Ad

Most websites have the current year displayed next to the copyright notice in the footer. But having to manually update it year after year isn’t ideal, no?

Fortunately, programming languages, frameworks, SSGs, and such, usually provide an easy way to handle dates, especially when it’s something simple like displaying the current year automatically.

If you’re using Hugo for your website or blog, as I am, here’s how to do it.

Automatically displaying the current year in Hugo is easily done using one of its built-in functions.

All you have to do is to go to your footer.html partial, or wherever your footer’s HTML code is, and use one of these two codes based on the “now” function:

  • now.Format "2006"
  • now.Year

So, the HTML code should look like this:

<p>
    <small>Copyright &copy; {{ now.Format "2006" }}</small>
</p>

Or, with the alternative:

<p>
    <small>Copyright &copy; {{ now.Year }}</small>
</p>

Note that with this code now.Format "2006", you don’t have to change the year between the quotes. That handles the format and reference time (2006) that many programming languages use, if not all. From what I understand, it has something to do with ISO 8601.

Of course, you can use this function to display the current year wherever you want on your website, not just the copyright footer.

That’s a Wrap

I hope this post has helped you out.

If you're interested in my web design services or templates, want to collaborate, or just have something to say, feel free to shoot me a message.

About Radu

I've been working online from home for over 11 years, gaining valuable experience and developing a wide range of skills, including web design and development, optimization, and SEO.

More posts