How to Automatically Update the Copyright Year on Your Website

0
6

Updating the copyright year on your website may not be a legal requirement, but it’s smart marketing. It tells the visitor the site is active. Showing the current year is especially important if you have a brochure site without dates on its content.

You can automatically refresh the copyright year by inserting a simple JavaScript or php script (see below) into your website’s html code.

Entering either script won’t change the year in the Design view of your html editor. To see the results of your handiwork, upload the edited web page to your web server, go to your browser and reload the page. Here’s the JavaScript. Copy and paste it wherever you want the current year to appear:



And here’s the php script:

Yes, the php script is simpler, but it may not work just yet. You first need to take another step to make the php script run on html pages. You need to create or edit a .htaccess file. This is not as onerous as it sounds. It’s actually a good thing, because then you’ll be able to run other php scripts on your site, which can be extremely useful.

Creating the.htaccess File

To set up a.htaccess file, open a new file in a text editor like Notepad or SimpleText.

Paste the following code into the file:

AddType application/x-httpd-php.htm.html

If you have an existing.htaccess file, open it and add the above code.

Alternatively, search your web host’s site for “How to parse php within html files.” Follow its instructions on what code to enter in the.htaccess file. (Your web host might specify an entirely different process for parsing php in html pages. Follow those directions instead of the ones here.)

After inserting the code, in Notepad click File > Save As…

Type .htaccess as the file name and from the Save as type dropdown menu, select All Files.

Click Save, then go back and make sure the editor didn’t add an extension to the filename after.htaccess. If you find an extension, delete it.

Upload the.htaccess file to the root directory of your website. This is the topmost folder of your website’s file structure and is usually named example.com or example.com/home.

The.htaccess file now affects every other file in your website.

Updating Your Blog’s Copyright

Depending on the blogging platform you’re using, you may not have access to the.htaccess file. In that case, use the JavaScript.

Copyright That Spans Several Years

A range of years next to your copyright symbol subtly reminds the visitor how long you’ve been in business or how long your website has been up. Use the script to update the last year of your range.

Copy and paste the following as your copyright notice’s html code. Change 2002 to the year in which your site was established:

Copyright © 2002–

Then enter the JavaScript or php script for the current year.

Your copyright year updates are now on autopilot. One less thing to worry about at 12:00:01 a.m. next Jan. 1.

Source

Leave a Reply