W.K.S
W.K.S

Reputation: 10095

How to template a simple website

I'm new to Web Development so excuse me if this question sounds dumb. I'm making a website for a small business which only lists the services they provide: there's no database backend or anything like that.

The design for each page will look the same, only the content changes. I have defined the design in one HTML file and the content in different HTML files. The content HTML is loaded into a particular div of the design HTML using the code below:

<?php

include 'php/load_template.php';

    $home_contents = file_get_contents('html/home.html'); 
    load_template('page.html',array('{Content}'),array($home_contents));

?>

Is this a good approach to solving the problem?

Upvotes: 1

Views: 190

Answers (1)

Trevan Hetzel
Trevan Hetzel

Reputation: 1369

I would say that that approach works, but you might want to look into something like Grunt.

I've used Grunt on a couple projects now and it's very nice to be able to use "partials" in your development workflow. Basically, Grunt lets you structure your local HTML files and assets in ways that make it easy to separate out different sections, but yet compiles it to static HTML files for you. It can do a lot more of course, but just using it for partials would be a good start for you I'd say.

This way, you're not relying on PHP or a server-side language. You don't have to set up a server or anything!

Upvotes: 1

Related Questions