views:

79

answers:

5

I'm designing a simple website with no dynamic content that I want to be light and portable — no PHP or other server-side scripting needed, or wanted. I'm running into a question that I've had a few times before.

I'd love to be able to write common elements (head, foot, navigation) once and write the individual pages on the site with content only, then run this mysterious utility to compile everything it into a set of HTML files ready for uploading. A page might be written like this:

Title: Our Services
Top Navigation: Yes
Scripts: jquery, lightbox

<p>
    Example, Inc. offers a wide range of…

It'd be great if the engine also had logic that lets me include or exclude elements (like Top Navigation above) from each page, and automate tasks like labelling the current page in the navbar:

<a href="/services"{page == 'services' ? ' class="current"' : ""}>Services</a>

Are there any engines out there like this?

+3  A: 

I'd head directly towards Template-Toolkit for this. It comes with the ttree utility for building a static site.

You can handle the last part of your question with something like:

[% 
    INCLUDE 'navbar.tt' 
    page = 'services'
%]
David Dorward
That looks nice, easy and flexible. Thanks.
Sidnicious
I'm actually starting to build a site with Template Toolkit now. Awesome recommendation.
Sidnicious
+1  A: 

To be honest, this is where things like PHP come in handy... to include common elements

Option 1: Use a language and enjoy it.

Option 2: Use the language to make the site... but then point a crawler at your site to grab the generated "static" content. e.g. WinHTTPTrack

scunliffe
A: 

Adobe Dreamweaver's Templates do what you need if a non free tool is fine for you.

Basically you create a Template page where you define which parts are editable, then you create all your pages based on the template. If you change the template and save it all the associated pages are updates.

The templating system also has the ability to define default attributes and change them in a specific page. You can use this for labeling the current page, though for this IMHO a couple of lines of jquery code are much better.

filippo
+1  A: 

Webby is fantastic for exactly this.

Another great option is Jekyll.

Both of these look awesome. I'll keep them in mind for future projects.
Sidnicious
A: 

You could write a program in any language you are familiar with that outputs static html files. You could have a basic structure and then for the customized stuff, you include it from a separate file.

chiurox
I asked for an existing solution, not a homework assignment :P .
Sidnicious