webgen / webgen
Static site generator written in PHP.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 1
Language:HTML
Requires
- php: >=7.2.0
- czproject/logger: ^0.11.0
- czproject/path-helper: ^4.1
- kukulich/fshl: ^2.1
- latte/latte: ^2.4
- nette/finder: ^2.4
- nette/neon: ^2.4
- nette/robot-loader: ^3.0
- nette/utils: ^2.5
- texy/texy: ^2.9
Requires (Dev)
- nette/tester: ^2.0
This package is auto-updated.
Last update: 2024-02-29 03:31:13 UTC
README
Simple PHP CLI generator of static web sites.
Features
- Texy! support
- Latte templates support
Usage
$ cd examples/basic
$ php -f ../../webgen.php -- --run
$ cd output
$ ls
articles index.html
Note: Webgen ignores files with @
on start of filename.
Templating
Texy in Latte template
{block |texy} This is **Texy** snippet. {/block} {texy} This is "Texy":https://texy.info snippet too. {/texy}
Get name of current generated file
{$webgen->currentFile} {* prints for example: 'articles/article-2.texy' *}
Get relative path from currentFile
to a file
{$webgen->createRelativeLink('articles/article-1.html')} {* prints: 'article-1.html' for currentFile = 'articles/article-2.texy' 'articles/article-1.html' for currentFile = 'index.texy' *}
Shortcuts (output for currentFile = 'articles/article-2.texy'
)
{link articles/article-1.html} {* prints article-1.html *} <a n:href="articles/article-1.html">Article #1</a> {* prints *} <a href="article-1.html">Article #1</a> <link rel="stylesheet" n:href="css/style.css" type="text/css"> {* prints *} <link rel="stylesheet" href="../css/style.css" type="text/css"> <img n:src="images/photo.jpg"> {* prints *} <img src="../images/photo.jpg"> <img n:image="images/photo.jpg"> {* prints (image file must exist) *} <img src="../images/photo.jpg" width="1024" height="768">
Relative paths in Texy:
"Article #1":@articles/article-1.html
[* @images/photo.jpg *]
Highlight current page in menu (is link current?)
<div id="menu"> <a n:href="/" n:class="$webgen->isLinkCurrent('index.texy') ? current">Homepage</a> <a n:href="about-us/" n:class="$webgen->isLinkCurrent('about-us/**') ? current">About us</a> <a n:href="contact.html" n:class="$webgen->isLinkCurrent('contact.*') ? current">Contact</a> </div>
In mask **
means everything, *
means everything except /
.
Variables in Texy document
{{$var}}
{{$var = value}}
{{$var: value}}
Configuration
Configuration is stored in file named config.neon
. NEON is format very similar to YAML, see https://ne-on.org/.
Change name of source or output directory
input:
dir: <new-source-dir-name>
output:
dir: <new-output-dir-name>
Change name of layout template
input:
layout: @my-layout-name.latte
Copy files from source directory into output directory (CSS & JS files, images,...)
Boolean value (yes
/no
) or filemask(s):
input:
copy: yes
input:
copy:
- *.js
- *.css
Change default output file extension
output:
ext: php
File-specific change:
{webgen ext => php} ## in Latte template {{webgen: ext: php}} ## in Texy file
Change output filename
## changes output file extension {webgen ext => php} ## changes output basename of file {webgen name => my-first-page} ## changes output filename (ignores 'ext' option) {webgen filename => my-first-page.html}
Pagination
See example pagination-repeated-generating.
Who uses Webgen?
Articles:
- https://www.janpecha.cz/blog/webgen-2-1/ (in Czech)
- https://www.janpecha.cz/blog/webgen/ (in Czech)
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/