View Full Version : Adding a piece of text to all web pages using code
04-22-2011, 08:58 PM
I need to have a disclaimer at the bottom of my pages that has the year 2011 in it for copyright. The year needs to be updated each year, even though the content stays the same.
Is there a way to apply a few lines of text to a web page by using a piece of code that would pull the text from a single file or folder so that when I update the year, it changes on all of the pages?
I could very easily have 500 or more pages a year, and it would take a long time to update all of them each January.
04-22-2011, 11:26 PM
WHy not create the footer separately and use a server side include. That way when you need to update the copyright code, you do it once and all 500 pages get updated. Just like a css file. Change one style and all pages that are linked to that stylesheet reflect the change.
PHP, Coldfusion, and I'm sure most of the others have this functionality.
04-23-2011, 01:30 AM
Yeah, to clarify: Search the internet for “server side include” (SSI) or “PHP include” (for the two most popular ones).
04-23-2011, 05:07 AM
<?php include "filename.html" ?>
04-23-2011, 02:19 PM
I went with
<!--#include virtual="/ssiads/pageads.shtml" -->
<!--#include virtual="/ssi/teecopyright.shtml" -->
both on the same page. This is really slick!
I needed to read up on it to understand "file" and "virtual," but I got it.
Thanks, teedoff and VIPStephan. I appreciate your help!
Aurora.Light, do you recommend the php over the <!--#include . . . code?
I appreciate any imput.
04-23-2011, 02:26 PM
I have another question. My site is just getting cranked up, so going back and adding the "includes" code on 30 pages isn't a problem, but is there a downside to having .shtml pages instead of .html pages?
I'll make all my pages .shtml to accommodate the "includes" code, but is this ill-advised?
Any input will be greatly appreciated.
04-23-2011, 03:26 PM
There’s no difference in using PHP or SSI except of the “language” used. In the end the page (and source code) looks the same as if it was static HTML. Also, the file extensions have no effect whatsoever on page ranking, rendering of code, or SEO. It’s just so that the server knows what to expect (i. e. static HTML or HTML with SSI). In fact, with some htaccess rules or server configuration you can have any extension you like (or even no extension at all).
However, for SEO you should note that changing page/file names that are already indexed in search engines from .html to .shtml (or anything else) you should put a 301 (permanent) redirect from the old file to the new one so that people won’t get a 404 error and search engines know that the page has moved.
04-23-2011, 04:00 PM
I appreciate you time and explanation.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.