I've a single template with a header, a logo and a footer, but multiple pages with different content.
Is there a way, instead of copying the page several times to create several pages with different content but same template?
I've a single template with a header, a logo and a footer, but multiple pages with different content.
Is there a way, instead of copying the page several times to create several pages with different content but same template?
yes you can, definitely! this, however involves php, but isn't hard ;-)
as I don't have any source code i'll give you a do-it-yourself snippet. put the following in your html code where you want the content to appear:
<?php
include('/some-location-or-url/somefile.php');
?>
where '/some-location-or-url/somefile.php' is the path to a .php file containing the html you wish to display in that location.
Now, I know this only displays one piece of html in a php file, but for example by adding this (instead of the above snippet):
<?php
if($_GET['id'] === '1')
{
include('/some-location-or-url/somefile.php');
}
if($_GET['id'] === '2')
{
include('/some-location-or-url/some-other-file.php');
}
?>
... we can have different content based on the $_GET variable. (this is basically what's behind the ? on a php page. (E.G. google.com?id=1) for this all to work, you'll need to rename all .html extensions to .php (as far as I know))
I hope this guideline helps. EDIT: for more info see this article. see a working implementation here.
As long as you're running from a server-based operation (not local on your computer or local area network), you can use the <!--#include virtual="insertthisfile.html" -->
. This allows you to include html information from an external text file, which can be your template.
You'll want to include just the template information, because you've already declared your header information (like <!DOCTYPE HTML>
, etc. So you may have a top-banner on your main site. You cut this out of your main site and paste it into a text file (or html file, which is more preferred). You then ensure the relative location is added in the above insderthisfile.html
location.
When you preview it on your own computer, you won't be able to see it (some editor preview functions allow the include to function, but some don't). You'll need to upload it to your web server and view it there. I recommend putting it in a special directory, not your main directory, and that you clear it out after you preview.
More detailed information on includes can be found here: http://www.boutell.com/newfaq/creating/include.html.
I know two ways of doing this
Using a software handling the changes on your pages using a template html page. For example Dreamweaver does that : http://webdesign.about.com/od/dreamweaverhowtos/ig/Create-a-Dreamweaver-Template/
Otherwise you can use a server side language such as PHP in order to inject your different contents using a template http://coding.smashingmagazine.com/2011/10/17/getting-started-with-php-templating/
As @j086691 said in comment, you are going to need another language.
An article about it into webdesign.about.com
Once you’ve surfed the web for more than a day, you’ll notice that most websites have a theme or template for their site design that is repeated across every page on the site. On this site, there are several elements that are repeated in this way, including the header portion of the page and the navigation.