Web Design |
naming your files |
||||
main menushelp pagesprinter-friendly/text-only version |
To a large extent you can save your web pages under whatever name you like. But there are some restrictions, so this page runs through what they are. Though this seems a trivial issue, not remembering these rules is a common reason why web sites do not work, particularly with beginners. Remember also that a web site comprises not only HTML files, but also images, style sheets and possibly even video or audio files. These rules apply to all file types. First of all, of course, you have to follow the standard naming convention which is: filename.ext ext is the extension of the file type you're saving. For HTML files it is .htm or .html. For other file types the extension will depend on the file, but by the time you're dealing with these kinds of files you'll know what extensions will apply.
filename is your choice, but you are best limiting it to something under about 20 characters. The name of an HTML file is usually (though not always) shown at the end of the URL, which will appear in the browser's location bar. Therefore, you can see that the file you're looking at at the moment is called subj_naming.html. If you followed the virtual lecture for this lesson, you should already have named and created a file called firstpage.html. There is one special name you should be aware of. That is index.html. Your site's front page - the page which visitors see first - should be given this name. There are two good reasons for this. The first is that it means you get a better-looking URL. You may notice that a lot of URLs - like http://www.leeds.ac.uk/ - don't have a filename visible at the end. If a browser gets given a URL which does not end in a filename it will assume it is looking for a file called index.html. (You can actually change this, but it's a very advanced issue and not worth worrying about now.) In other words, that URL is effectively the same as http://www.leeds.ac.uk/index.html. The second reason is connected to this. If you don't have an index.html file and someone comes looking for it, they will in fact see a listing of all the files on your site. This is a mild security risk, but it also looks very sloppy. So an early habit to get into is to always name your front page index.html. You should definitely avoid spaces in the filename (that is, first page.html). The underscore (_) character is the usual "replacement" for a space, if for whatever reason, you want to have a two-part filename. Honestly, don't use spaces, though it seems such a trivial thing (and you do sometimes see them used online). Browsers don't like them, often replacing them with other characters. Had I used a space in the name of this file, the URL might have become http://www.leeds.ac.uk/acom/webdesign/subj%20naming.html. It doesn't necessarily make it harder for browsers to find the file but you may want to publish the URL of your site and that's obviously more difficult to type. It looks ugly too. All in all, it makes sites less robust. Also don't use characters other than the underscore or the hyphen (-) if you can help it: definitely avoid characters like %, ?, #, which have other special uses in Windows. As a further example, these links go to two other pages in this lesson. A file called subj_tags.html You will need to refer back to these filenames when you use internal links, which we will come to in lesson 3. When we do this you will see that the full file name - or what is known as the path name - of a file may also include references to folders. While we're still only dealing with single web pages, though, that is not an issue so we will not worry about it until then. |
Material on this site is © Drew Whitworth, 2005 Permission will usually be given to reproduce material from this site for non-commercial purposes, if credit is given. For enquiries, e-mail Drew at andrew [dot] whitworth [at] manchester [dot] ac [dot] uk.