Forum Moderators: open
I did a search here and found a mention of using something called "includes" to make separate files for these page sections. Then they can be edited once and will make the changes sitewide.
Does the use of includes affect accessibility for the blind?
Can anybody explain to a newbie how to do this? FWIW, the only languages I know are HTML/XHTML and a wee bit of CSS.
Thanks!
The principle is dead simple:
You could have, for example, a links.html with all the link for your left margin; each page would just have 'include links.html' code in that spot.
So whenever you wanted to add a link, you'd revise the one file, upload it, and every page would change.
As all this happens at the server, the page itself would appear as if that code had been there all the time, so no implications either way for accessibility.
You'd need to edit each page once to insert the 'include' code, then it's a doddle.
I use them for dates, news, advertisements, links ....
I write with a text editor, not any page building software. I need an easier way to make sitewide changes to, say, the navigation panel or footer. Opening each and every page to cut, copy and paste is taking waaaaaaay too long.
Befoe considering includes, consider a robust page editor. I use Macromedia Homsite. If your "target text" is identical throughout, H.S. can rip through a thousand files on an extended search and replace in about 5 seconds. There are many robust text editors that can do this. The reason this is a good idea is so that your include files html doesn't require new URL's but there are workarounds to that too.
Does the use of includes affect accessibility for the blind?
Can anybody explain to a newbie how to do this?
As mentioned for windows servers it's different. For linux, verify that SSI's are turned on. The simple test below will tell you if it is enabled or not.
"Turned on" means you need your server to parse the documents and search for the SSI directive, indicated by the "include" line below. Normally a server parses documents only with an .shtml extension, but for SEO purposes you may want your server configured to parse all HTML for SSI includes. This is so your URL's don't change. Contact your ISP on how to set this up.
Le's consider the usual condition, you have a file named test.shtml:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Include test</title>
</head>
<body>
<h1>Server Side Includes</h1>
<!--#include file="test.txt" -->
</body>
</html>
then in test.txt:
<p>Hello world, this is my first include file.</p>
Throw these on your server in a test directory and see if it works.
Two important considerations:
1. The spaces before the closing --> are important.
2. If you store your included file in a DIFFERENT directory than the .shtml, use the virtual directive:
<!--#include virtual="/web/includes/test.txt" -->
If you get "An error occurred while processing this directive" it means that SSI is indeed operational but that you have an error or typo in your .shtml, and usually simply means the server can't find the file from the instructions in your directive.
That's really all there is to it.
For example, if PHP includes are used for global navigation (works the same way as SSI, BTW), changing just the one text file implements the change across the entire site, on whichever page the include is used, without having to upload anything new.
My host uses a Linux server. He tells me that SSI is available for .shtml files. I use Linux, too, not windows. My text editor is Kwrite.
I did what rockinbil suggested. Made a directory called "includes", copied and pasted both files and put them in it. Uploaded and went online. All I got was permissions error messages. So I fiddled with permissions, making them the same as for Awstats, which I can access. No joy.
I like the idea of making changes via includes rather than from a batch change in a text editor. Seems a little safer and there's less uploading, too. But if I'm forced to use an editor, is there an easy one you can recommend that works in Linux? (I'm dumb when it comes to learning how to use applications.)
Any ideas what I should try next?
Siri Amrit
The filenames need to end in php (unless you want to go around rewriting them which is probably not the stage to get into that kind of thing).
A php include looks (can look, there are other options) like this:
<?php
{
require_once("pathtomy/file.php");
}
?>
and what goes in the include file is exactly what would be in the html in the original page and nothing more.
Common uses for include files are navigation (easy sitewide changes), headerimage (seasonal changes, for example), footer (copyright changes - I've given up arguing the point about the year!), quicknav (boost to certain pages).
Added: here's a quick way to see if you can work with it >>
Save a current page as the same name but with a php ending. Add in the following code somewhere:
<?php
{
require_once("test.php");
}
?>
Now open a text editor and write the following in a blank file:
<p>Hello world</p>
and save the file as test.php in the same directory as the original file.
Upload both files to your server and see if you can see "Hello world" on your php page.
How will changing all my pages from www.widgetstore.com/widget.html to www.widgetstore.com/widget.php affect my search engine rankings? Will I have to start out all over again at the bottom? What about all the people who have bookmarked my pages, if I go and change them from .html to .php? Will they get "Page not found" errors? I also have listings in directories all over the internet pointing to pages ending in .html. Can't possibly go back and change all those...
Each page will be treated as a new page; but your site will assimilate them quickly, like any other new page.
You might consider uploading the new stuff in sections, however, rather than the whole lot in one go, to avoid any risk of 'new site' issues.
While you won't see page rank for three months or so, that doesn't mean there isn't one!
There are server tricks to workaround; but for me, updating in sections has always worked (just watch the navigation! - xenu is your friend).
Parsing HTML as PHP [webmasterworld.com]