Leonardo
Leonardo

Reputation: 23

Jekyll includes not working in GitHub Pages without a template

I'm trying to publish my own website on GitHub Pages. I want to include some repeating parts of code (header) in many files so that I don't always have to copy-paste them. I wanted to use the include functionality offered by Jekyll:

{% include example.html %}

I've put the file I want to include in the _includes directory, however, for some reason it seems to work only if I use a layout in the main file. Am I doing something wrong? If not, is it possible to use Jekyll includes without a layout? (Because I have set all my html files to work without it)

Upvotes: 2

Views: 1573

Answers (1)

Brad West
Brad West

Reputation: 969

My best guess is you are also removing the yaml tags when you remove the layout. Try this in your index.html file

---
---
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>First try</title>
  </head>
  <body>
    {% include first-try.html %}
  </body>
</html>

You need those --- tags to process Liquid in the file.

Upvotes: 8

Related Questions