Plain HTML has no built-in way to pull one header or footer file into every page. To keep them the same across a static site, you either let the web server stitch the parts together (server-side includes or PHP includes), load the shared parts with JavaScript, use a static site generator, or use an editor that keeps a shared header and footer and writes it into every page for you. Each approach works; the right one depends on your host and how comfortable you are with code.
This guide explains each option, shows a short example of each, and lists the trade-offs so you can pick the one that fits your site.
Why copying the header by hand goes wrong
On a small site, the usual approach is to copy the header and footer into each new page. That works until you need to change something. Add a menu item or update the phone number in the footer and you have to edit every page, one at a time. Miss one and visitors see an old menu on that page, or a link that goes nowhere.
Common symptoms of copied headers drifting apart:
- A new page is missing from the menu on some pages but not others.
- The copyright year or contact details differ from page to page.
- The "current page" highlight in the menu is wrong because a page was copied from another.
- Pages in subfolders have broken menu links because the links were copied with the wrong relative paths.
Any of the methods below solves this by keeping one master copy of the shared parts.
Option 1: Server-side includes (SSI)
Server-side includes are an old, simple web server feature. You put the header in its own file, then add a special comment where you want it to appear. The server replaces the comment with the file's contents before sending the page to the visitor.
<!--#include virtual="/includes/header.html" --><!--#include virtual="/includes/footer.html" -->
Things to know:
- SSI must be enabled on your server. Many hosts that run Apache support it, but not all do.
- Pages often need the
.shtmlextension for the server to process them, unless your host is configured otherwise. - The includes do not work when you open the page straight from your hard drive. You only see the full page when it is served by a web server.
Option 2: PHP includes
If your host supports PHP (most shared hosts do), you can rename your pages to .php and include the shared parts with one line each:
<?php include 'includes/header.php'; ?><?php include 'includes/footer.php'; ?>
PHP includes are reliable and fast, and the visitor (and search engines) receive one complete HTML page. The downsides are similar to SSI: your host must run PHP, renaming pages changes their addresses (so old links and bookmarks may break unless you set up redirects), and you need a local web server to preview the pages properly on your PC.
Option 3: Load the parts with JavaScript
You can also leave an empty placeholder in each page and have a small script fetch the header file and insert it. For example, an empty <header id="site-header"></header> filled by a script that requests header.html.
This works on any host because nothing runs on the server. But it has real drawbacks:
- The menu appears a moment after the rest of the page, which can cause a visible jump.
- Visitors with scripts blocked, and some tools that read your pages, get no menu at all.
- Search engines can run JavaScript, but links that are written directly in the HTML are the most dependable for crawling.
- Browsers usually block these requests when you open the page from your hard drive, so local previews may show a blank header.
Option 4: Generate the pages before you upload
The last approach is to keep the shared parts in one place on your PC and have a tool write them into every page before you publish. Static site generators do this with templates, and some HTML editors do it with shared headers and footers. The result is ordinary, complete HTML pages: every page contains its own copy of the menu, but you never edit those copies by hand.
This is often the best fit for small static sites because the published pages need nothing special from the host, work offline, preview correctly on your own computer and are easy for search engines to read.
Comparing the options
| Method | Needs host support | Previews on your PC | Menu in the HTML visitors get |
|---|---|---|---|
| Copy by hand | No | Yes | Yes |
| Server-side includes | Yes (SSI) | Only with a local server | Yes |
| PHP includes | Yes (PHP) | Only with a local server | Yes |
| JavaScript loading | No | Often not from a file | No, added after loading |
| Generated by a tool or editor | No | Yes | Yes |
Tips whichever method you choose
- Use root-relative links in shared menus (such as
/about.html) or let a tool manage relative paths, so links work from pages in subfolders. - Keep shared files in one clearly named folder, for example
includesorpartials. - Put the page title and meta description in each page, not in the shared header, so every page keeps its own.
- After changing the menu, click through a few pages at different folder depths to check the links.
The easier way: shared headers and footers in Apollo Editor
Apollo Editor is a Windows desktop HTML editor that includes shared headers and footers as part of its Site Explorer. You edit the shared parts once and the pages in your site use them, while your site stays as plain, portable HTML with no proprietary project format.
- Shared headers and footers managed alongside your pages in Site Explorer.
- Navigation management and a visual site structure tree, so you can see how pages connect.
- Relative link management and a broken link checker to catch menu links that point nowhere.
- Drag-and-drop header, navigation bar and footer components you can edit visually in Design mode.
Because the result is ordinary HTML, it works on any host without SSI or PHP. If you are setting up a site from scratch, see how to organize your website folder, and for checking menus after a change, read how to find broken links on your website. You can also see the full feature list.
Frequently asked questions
Can plain HTML include another HTML file?
Not by itself. You need a server feature such as SSI or PHP includes, JavaScript, or an editor that updates every page for you.
Is loading the menu with JavaScript bad for SEO?
Search engines can run JavaScript, but links written directly in the HTML are the most reliable for crawling and for visitors without scripts.
Do server-side includes work on every host?
No. Check whether your host supports SSI or PHP before relying on them, and note that pages may need a .shtml or .php extension.
