Composite, simplest static site generator

The simplest static site generator to create a website and then put it online. Free, open-source.

Composite, générateur de site statique

Composite is a PHP script that performs all page composition tasks locally before transferring them to the server, where they function as simple HTML pages.

This primarily allows for the reuse of the same header and footer, with PHP variables assigned to each page based on its content.

For example, the title and description of articles are assigned to each page and are inserted by Composite into the header when the page is published.

Case of PHP files interacting with the server

PHP files that are called by website pages, for example, to access or modify a database, should not be treated like static pages. There are two ways to distinguish between them:

1) By extension.

By default, the script composes pages with the HTML extension (which you can change). Therefore, PHP pages that need to run on the server (or other server-side languages) will be transferred directly without local execution.

Only pages with the HTML extension are executed locally, unless you have chosen a different extension.

2) With a separate directory

For example, you can place the website pages in example.com and the executable files on the server in example.php.

The contents of the example.com directory will be uploaded by Composite.
The contents of the example.php directory can be uploaded by Composite with the -u option, or with FTP Synchronizer.

Composite only transfers modified or new files to the local directory. On first use or with the -a option, all files are transferred.

The files transferred by Composite to the server are also copied to a backup directory (in their original state before code execution). The program compares each file in the local directory with the backup directory and thus determines which ones have been modified.

Manual

The following command will compose the pages contained in the local directory example.com and transfer them via FTP to the server:

php composite.php -lxxxxx -pxxxx c:\example.com -fxxxx -dexample.com/ -bd:\example.com -wexample.com %1 

It is best to put the command in a batch file; on Windows, this could be:

example.bat 

The %1 option in the command allows you to add extra parameters if needed, such as -t for a preliminary test.

example.bat -t

Parameters and options:

Example of template

In this example, we have a header.html and footer.html file that are common to all pages of the site.
Each page contains PHP variables used by these two files to fill the tags.

header.html

<!DOCTYPE html>
 <html lang="fr">
 <head>
  <meta charset="UTF-8">
  <title><?php echo $title?></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
  <meta name="description" content="<?php echo $description ?>">
  <link rel="stylesheet" href="https://example.com/example.css">
</head>
<body>
 <div id="header">
  <a href="https://example.com/">
   <div id="logo"><img src=""></div>
  </a>
 </div>
</div>  

footer.html

<div>
© Copyright <?php echo $date;?>
</div>
</body>
</html>

page.html

<?php
    $title="";
    $description="":
    define('ROOT_PATH', $argv[1]);
    include(ROOT_PATH.'/header.html');
?>
<div id="content">
  <h1><?php echo $title?></h1>
  <p><?php echo $description?></p>
  
  <?php
    $date="2026";
    include(ROOT_PATH.'/footer.html');
  ?>
</div>

Download the script

composite.zip

Licence GPL 2.0.

Exemple de site utilisant composite:

Webscript.fr/en/.

See also: