This is a handy little tool for creating static sites using PHP. It is a consolidation of different snippets and ideas that I changed to my needs. My goal is to create a lightweight static site generator with SEO Tag implementations and multilanguage support.
- Download & install PHP.
- Download & install Composer.
- Fork/clone the repository or download the repository as a .zip folder and unzip it.
- Start building your pages
- you can place your pages in "/src/pages/" - the build script will automatically use all .html files inside of this directory
- if you want to build a multilanguage website, you can use the $languages variable in the config.php to define country codes for the subdirectories (e.g. "en" for english or "de" for german) - the subdirectories will automatically be generated
- Use templates and includes
- use templates to extend your pages with predefined html (default directory is "src/templates/")
- pages can extend a template by calling the following function in your page:
startExtend(string $template, array $variables)
endExtend()
- This will extend the content of your page with the corresponding template file. Example usage in your .html file (where "default.html" is a template in "src/templates/"):
<?php startExtend("default.html", []); ?> <main> <h1>This is the page content</h1> </main> <?php endExtend(); ?>
- pages can extend a template by calling the following function in your page:
- use includes to include blocks of html in your pages (default directory is "src/includes/")
- includes can be used to extend pages, templates or other includes:
startInclude(string $include, array $variables, bool $print)
- This will extend the content of your page with the corresponding template file. Example usage in your .html file (where "nav.html" is a file in "/src/includes/"):
<?php includePart("nav.html", []); ?>
- includes can be used to extend pages, templates or other includes:
- use templates to extend your pages with predefined html (default directory is "src/templates/")
- Use enviroment variables for staging and production environments
- the files "env.prod.php" and "env.stage.php" are used for enviromental variables
- building the website will default to "env.stage.php" - using the "--prod" tag while building will switch to production variables ( in "env.prod.php")
- Generate the static sites by using the build script via the terminal - the output files will be placed in "public/"
or
php build.php # for staging variables
php build.php --prod # for production variables
To do.
No tests have been applied yet.
- Multilanguage support
- support for language specific includes
- support for language specific variables
- SEO generator
Contributing is not intendet yet.
This project is licensed under GNU General Public License v3.