I have a 30-page site set up on CSS and HTML. Every time I want to add or change a link on the sidebar, I need to make it 30 times. I know there is an easier way and keep seeing references to "includes". Can anyone give me some pointers on what I need to do?
FrankCow is right, use SSI... This is a simple example, how I use SSI to help out... Almost everything is stored in external files, so it's easy to change the entire site...
Thanks guys. Looks like that will work. It looks like I have to re-create all .html files as .shtml. What do I need to do about all of my inbound links? Do I need to set up a whole bunch of 301 redirects or will browsers automatically pass traffic along to .shtml files?
Ooo, I would not use redirects or change your page names if you care at all about SEO (Search Engine Optimization) or where you pages are in the search engines. I would strongly suggest PHP. You only need to learn like 5 lines of code in php and the rest you can do in HTML. Is your server running PHP?
Yes, it does run PHP. I definitely don't want to take an SEO hit. What would I need to do to keep my current html files?
This is a pretty simple way around it and without having to know much php. Create a new file called header.php (or whatever you name it) and include the following: <? function printHeader() { ?> <!-- Normal HTML code goes here. --> <? } ?> Code (markup): At the top of each html page that you want to include your header, before the <html> tag, put this: <?php include('header.php');?> Code (markup): header.php being the file with all the header code. If you put it in a folder then you will need to change the path to be folder/header.php and so forth. Then, where ever you want the header to be located in each file, place this tag: <?php printHeader(); ?> Code (markup): You might have some issues if your .htaccess file is not set to read php code in an html file. If so, add the following code to your .htaccess file: AddType application/x-httpd-php .htm .html .php Code (markup): This way, you just need to change the one header.php file and all your other pages will be updated automatically. You can do this for a footer, sidebar, or whatever you want. The bots see your page exactly the same though. This will not hurt your pages SEO wise at all and you will not need to change the names of your files. Hope this helps!
Changing .htm and .html files into .php files seems dangerous... I wonder if there's any side effects to that?
Using a SSI would be your best bet. But it depends if your server supports any SS languages, which it probably will, but you never know. Other than that there is always frames (which I won't recomend and hope for everyone that you don't use them). ps JDare, you don't need half that stuff you said. <? function printHeader() { ?> <!-- Normal HTML code goes here. --> <? } ?> Code (markup): only needs to be this: <!-- Normal HTML code goes here. --> Code (markup): and then place this wherever you want the header to go: <?php include('header.php');?> Code (markup): No need for the function. It's very unlikely that someone would put their header in twice, or a set of links in twice on one page, which is the only reason for using a function.
True, I only put in the function just in case you put other functions in the same file. You could put your header, sidebar, and footer all in one file if you really wanted by just creating different functions. But if you only want to do one thing, twistedspikes has a point.
As an experiment try renaming one of your pages to PHP, try a 301 on another and .shtml on the last and see what the effect is. Are you making the same changes in each file, i.e. adsense change, link change etc? Perhaps a tool like grep could help. Cheers
How could you guys forget about the PHP and Server Side Includes thread I've linked to in my signature here already? (By the way, that link goes to a thread here on the Digital Point Forums.) http://forums.digitalpoint.com/showthread.php?p=2145250#post2145250