Jekyll is great a way to start static website on Github Pages. But Jekyll has one big problem - the language. How would you add custom Twig or Latte filter to Jekyll?
I wanted to migrate my static websites from Jekyll to Statie. Can new init
command make this piece of cake? And what needs to be done next?
Statie 5.3 brings new init
command, that creates basic structure in /source
directory, statie.yml
, .travis.yml
and metafiles.
Before we start any moving, create a basic structure to save many copy-pasting steps:
composer require symplify/statie
vendor/bin/statie init
Then, clean /source
directory from generated files and...
/source
Directory/source
directory, so the website is separated from PHP code, tests, metafiles.-CNAME
+/source/CNAME
-index.html
+/source/index.html
-_data/projects.yaml
+/source/_data/projects.yaml
parameters > [param name]
SectionsBefore - Jekyll
# _data/projects.yaml
-
name: Symplify
url: https://github.com/symplify/symplify
After - Statie
# source/_data/projects.yaml
parameters:
projects:
-
name: Symplify
url: https://github.com/symplify/symplify
-https://github.com/TomasVotruba/gophp71.org/edit/master/_data/projects.yaml
+https://github.com/TomasVotruba/gophp71.org/edit/master/source/_data/projects.yaml
statie.yml
+imports:
+ - { resource: "source/_data/projects.yaml" }
site.data.
and use Variables Directly <ul>
- {% for project in site.data.projects %}
+ {% for project in projects %}
<li><a href="{{ project.url }}">{{ project.name }}</a></li>
{% endfor %}
</ul>
Thanks to vendor/bin/statie init
you have correctly configured .travis.yml
in your repository.
To finish deploy, you need to:
gh-pages
branchHow you do this? Just follow Statie.org documentation step by step.
In Jekyll, it's required to have ---
section in files, even if empty. You can drop it now:
- ---
- ---
HTML
...
This is what I missed the most at Jekyll page - instant feedback. We want to develop and see output instantly - is it correct or is there a bug?
npm install
gulp
localhost:8000
to see your generated HTML./source
? → Just refresh browser to see re-generated HTML.This is at least 100 times faster than deploying to Jekyll and checking the output in the production.
That's it! You can enjoy Markdown, Twig and PHP directly from your local machine and still on Github Pages.
Happy coding!
Do you learn from my contents or use open-souce packages like Rector every day?
Consider supporting it on GitHub Sponsors.
I'd really appreciate it!