Open GabLeRoux opened 5 years ago
Btw, providing an example theme written in twig
would be very handy. If someone manages to get one working, comment here! :v:
Took a bit different approach.. Made a new directory in themes/ , set the theme-property in the"main" _config.yml to the name of that new folder containg the theme. Added some files in that theme-folder:
- _config.yml containing:
menu:
Home:
- layout.twig containing:
{{ body }}
- index.twig containing:
{{ extends 'all.page.single.twig' }}
{% block content %}
Feel at home?
{% endblock %}
- all.page.single.twig containg:
<body>{% block content %}No content added in extending file.{% endblock %}</body>
The message says blog/themes/landscape/layout/index.ejs but I'm guessing that is/should-be blog/themes/landscape/layout/layout.twig .
So I wanted to convert a Craft CMS website into a static website. A quick search on https://staticgen.com led me to Hexo, which mentions it supports Twig templating. It wasn't too clear at first, but it turns out it does support Twig when using the
hexo-renderer-twig
package, which is neat šNow I replace the
index.ejs
template fromlandscape
theme with anindex.twig
with the following content:And it seems to be working well š
Now trying a simple condition just as in your readme:
:boom:
Note: Above error is huge, but updating this project's twig version to more recent version
Lead to a smaller error :P
Okay so the twig example is just wrong, twig can use ternary operators, but not with the
if
statement, let's write this in a different way:There you go
Now let's try to use twig for a page
Nuke everything from theme's layout folder and have this:
blog/themes/landscape/layout/index.ejs
blog/themes/landscape/layout/index.twig
result:
:fire: Should have been the following output:
:cry: So looks like the twig's
block
is failing here (or am-I doing it wrong?), what's going on? Even trying with no twig inindex.twig
or doing the same with ablog.twig
does the same. Or is this anhexo
issue? I think I'm lost šŗI know blocks in twig.js were rewritten here as they were a bit broken: https://github.com/twigjs/twig.js/pull/625
But even when using it with twig dependency being updated (see my fork) and #2 , I'm not able to get my theme to use
block
statements. I think I'll just go back to jekyll for now and convert thattwig
code intoLiquid
If someone passes by and knows the answer, I'm curious to know what's wrong anyway.