I have a GitHub pages site running Jekyll. I want to write a code block in a blog post, with the following content:
{% include file.html %}
Unfortunately Jekyll is reading this literally and including the referenced files content, i.e. the content of file.html. How do I explicitly tell Jekyll that this line should not be executed?
Use the raw tag.
{% raw %}{% include file.html %}{% endraw %}
Related
As mentioned in the Jekyll docs here, I have the following in my _config.yml as:
collections:
sections:
order:
- introduction.md
- battery-state.md
- vibe.md
- references.md
To render the content of each file within the HTML, I have the following:
{% for section in site.sections %}
{{ section.content }}
{% endfor %}
However, the content order is not presented as what I defined in the config file. How do I display the content in the order I defined in the config file?
Manually ordering documents in a collection was introduced in Jekyll 4.0
To use this feature, make sure that you're using Jekyll 4.0
For a site deployed on GitHub Pages, that would mean having to build the site outside GitHub Pages environment and upload the contents of the destination directory (_site).
You can also choose to add the sections to the front matter of the page. This is useful when you are not using Jekyll v4 or you want the user to be able to edit the order in CloudCannon, Netlify CMS, Forestry or another CMS with front matter editor.
sections:
- introduction
- battery-state
- vibe
- references
And the use a layout like this:
{% for s in page.sections %}
{% for section in site.sections %}
{% if s == section.slug %}
...
{% endif %}
{% endfor %}
{% endfor %}
I'm trying to build a static website using the GRAV CMS. So far, I've been creating *.html.twig files and associating a single page to the individual template.
This is how my pages look:
{% block header%}
{% include 'partials/bhss-default-header.html.twig' %}
{% endblock %}
#CONTENT
{% block footer%}
{% include 'partials/bhss-default-footer.html.twig' %}
{% endblock %}
However, my purpose is to have an editor creating pages from the admin interface and adding HTML blocks similar to the custom fields or shortcodes in WordPress. I want this blocks to be filled with text.
I need to mention that my website is built with Semantic-UI, so I'm not using any theme provided by GRAV.
How can I replicate this behavior and what choices do I have ? The website is small at this time, so I can remake every page.
Thank you!
If you want to use editor, you need to build your header and footer as Grav pages in Markdown, not Grav theme's template file in Twig. Example:
{% block header%}
{{ pages.find('/my-header').content }}
{% endblock %}
#CONTENT
{% block footer%}
{{ pages.find('/my-footer').content }}
{% endblock %}
my-header and my-footer are 2 pages. You can unpublish these pages to hide them from your menu and forbid direct access to them.
I have a Jekyll website and everything works fine, just it doesn't parse <h2> tags in markdown (I also tried putting the actual HTML and still doesn't work. Example: here or here. When I test it with a local server everything works though.
Source code for the /apps page:
---
layout: page
title: My Apps
---
Here's a list of all my published apps, sorted by platform.
[If you need Support and would like to open a ticket, please go to the Support page.](/support)
Most applications are available in English, Italian and Polish so far.
[Click here to take a look at the Patch Notes](/apps/patchnotes)
{% for member in site.data.apps %}
{% if member.link %}
##{% if member.fontAwesome %}{% for image in member.fontAwesome %}<i class="fa fa-{{ image }}"></i> {% endfor %}{% endif %}{{ member.name }}
<br><br>
{{ member.description }}
{% if member.bundleName %}Included in [{{ member.bundleName }}]({{bundleLink }}) bundle.{% endif %}
{% endif %}
{% endfor %}
[Source for app/patchnotes - Page Layout]
Try this:
## {% if member.fontAwesome %}
I just added a whitespace between ## and {℅
Let me know if it works, yeah?
Your Gemfile includes some dependencies like bourbon or time-to-read. Those are not supported plugins/gems (list of gh-pages supported gems/plugins).
If you leave only github-pages gem in your Gemfile and build or serve locally, it fails.
I think that Github pages is also failing but more gracefully.
If you want to work with "exotics" gems, you will have to generate locally and push the generates site on github.
How can I use the include_relative tag correctly?
I have my folder layout and files like so.
my-account.html
_includes
page-content
my-account
my-account.html
header.html
nav.html
In my-account.html I include the following file.
{% include page-content/my-account/my-account.html %}
All good.
However, inside the my-account.html from the includes folder, I am also calling header.html and nav.html
{% include page-content/my-account/header.html %}
{% include page-content/my-account/nav.html %}
Is there a way to use include_relative like this from the my-account.html since its in the same folder?
{% include_relative header.html %}
{% include_relative nav.html %}
Currently I get the error:
'./header.html' not found, so obviously the include_relative is not working.
Thanks!
Try this to the file my-account.html:
{% include /page-content/my-account/header.html %}
{% include /page-content/my-account/nav.html %}
I've tested here with a similar structure and worked, then you should be ok. ;)
I am developing an application using Symfony2 and twig for templates. I am using a 3 level structure for templates. Base.html.twig, layout.html.twig and childtemplate.html.twig.
The problem is I am trying to include one example.html (common html file) in the next child template by using include but it doesnt work properly. Where can the problem be?
{# src/Anotatzailea/AnotatzaileaBundle/Resources/views/Page/testuaanotatu.html.twig #}
{% extends 'AnotatzaileaAnotatzaileaBundle::layout.html.twig' %}
{% block title %}Testua anotatu{% endblock%}
{% block body %}
{% include "var/www/Symfony/web/example.html" %}
{% endblock %}
Depends on where it's located. Let's say it's in Anotatzailea/AnotatzaileaBundle/Resources/views/example.html.twig; then you would include it like this:
{% include 'AnotatzaileaAnotatzaileaBundle::example.html.twig' %}