Including Boilerplate Text

Including Boilerplate Text

If you have header or footer material which appears on every page in your site, such as navigation or copyright information, it makes sense to store it centrally and use server-side includes to make it appear where needed. That way, if you change anything, you only have to change it once for it to show up everywhere.

If you have header material in a file called header.html, you can include it in a page like so:


If the include files are stored in their own directory, you’ll need slightly different syntax:


For any of this code to work, you’ll need to make sure that your server is configured to parse HTML pages. Pages with server-side includes usually have the .shtml extension, to let the server know they should be parsed. It’s possible to configure your server to parse all HTML files, but that will slow everything down considerably.


Share the Post: