Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Repeating headers in HTML
ercatli
✭
This is the third time I've had to ask a HTML question on this Vanilla forum, but as the last answers were so simply helpful, I won't make any more apologies.
I want to be able to include the same information in a header on many HTML pages - in my case it is the same set of links, which I want to be able to update once when I add a new page, not dozens of times. I have searched the web, and got some clues, but I didn't get enough to do it myself. It seems like I need to use an "include" instruction, but it seems like I might have to use ASP or PHP, neither of which I know much about.
Can someone point me in the right direction please? Specifically ...
1. Can I do a recurring header just using HTML and CSS?
2. A few pointers on the best way to do this?
3. A website that explains it clearly enough for me to understand and use (unlike the ones I've found so far).
Thanks heaps.
0
This discussion has been closed.
Comments
2. Includes could be done with PHP or some other server-side script. It's very simple, as easy as one line of code. The simplest way would be using something called 'server side includes', which can usually be activated by naming your file "*.shtml" and inserting a HTML comment that triggers an include.
3. Example server side include.
A scripted include would look something like this, where everything else is standard HTML:
PHP: <?php include('file.htm'); ?> ASP: <% include ('file.htm') %>
I checked out the site you referenced, and also another one which was helpful - http://www.boutell.com/newfaq/creating/include.html. This site indicated several methods to include:
1. Server side includes as you note in 2, one using a simple command (don't know how further to describe it) and one using PHP.
2. Client side includes via javascript or iframe - these methods were NOT recommended.
I chose not to try PHP because I was uncertain about converting my HTML files to PHP. So I used the command in my page file. I wasn't sure which file had to be renamed xxxxx.shtml. so I changed both the page file and the "inserthisfile" to xxxx.shtml.
The include still didn't work, but I found out that my server also required me to have a ".htaccess" file with the following command in it: "options +includes". I didn't have a ".htaccess" file so I made one up, put the "options +includes" command in as the only line in it, uploaded it to my website root directory, and now it works.
Perhaps they may assist someone else. At least it tidies the matter up. Thanks again.