11

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?

1
  • Many content management systems will do this, though perhaps with not that simple of syntax.
    – DA.
    Feb 4, 2010 at 23:48

5 Answers 5

4

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'
%]
2
  • That looks nice, easy and flexible. Thanks.
    – s4y
    Feb 8, 2010 at 17:08
  • I'm actually starting to build a site with Template Toolkit now. Awesome recommendation.
    – s4y
    Feb 11, 2010 at 3:19
1

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

1

Webby is fantastic for exactly this.

Another great option is Jekyll.

1
  • Both of these look awesome. I'll keep them in mind for future projects.
    – s4y
    Aug 29, 2010 at 7:01
0

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.

-1

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.

1
  • I asked for an existing solution, not a homework assignment :P .
    – s4y
    Aug 29, 2010 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.