Layout Includes

A way to use javascript to include the layout on every page while only having to edit it on one page.

include.js

Where the magic happens. This script contains the HTML for your layout. What it does is it reads the page you include it on and looks for a div with the id 'content.' It fetches what's inside that div and then inserts it into this template. Then it returns the entire template to be rendered by the browser.

Your content

Create a page. Call it whatever you like. Include your html and your title.

Styling

Of course, you will want to style your page. Here is a style.css you can use if you want to get started right away.

And you're done! You can see what it looks like here. You can, of course, alter the template as much as you want. Make it one column if you'd like, change the colors, go wild! This is simply a barebones template you can customize. The purpose is to show what the final result of the includes will look like.

The downsides to this approach are twofold: it won't work if someone has Javascript turned off, and sometimes you may see the screen flash a little as the Javascript loads the content. Very few people browse without Javascript these days. As for the latter, well, nothing is perfect.