4

I'm currently using jekyll to build a static site and it appears that the HTML files are not parsing liquid.

My current directory structure looks like

_layouts
  page.html
index.html

index.html:

---
layout: page
title: home
---

{{ foo }}

When I visit http://host/index.html, the layout is applied as expected but the page doesn't evaluate {{ foo }} but instead prints the string {{ foo }}.

3
  • Just to be sure, you're visiting the url through jekyll server right? Nov 19, 2013 at 22:12
  • Yes, I'm accessing it at localhost:4000/index.html also, wouldn't this not make a difference since its going to output HTML anyways? Nov 19, 2013 at 22:14
  • I have this happening with html files, but md files work just fine. The "Step-by-Step Tutorial" fails on step 2 for me because of this.
    – user96622
    Nov 10, 2022 at 0:33

1 Answer 1

4

You don't show us where and how you defined foo.

There are several possible ways how to do that...and for each one, the syntax to display the value is slightly different:


In _config.yml:

Declaration:

foo: whatever

To display it on the page:

{{ site.foo }}

In the front-matter of the same page:

Declaration:

---
foo: whatever
---

To display it on the page:

{{ page.foo }}

In the body of the same page (e.g., not in the front-matter):

Declaration:

{% assign foo = 'whatever' %}

To display it on the page:

{{ foo }}
2
  • 1
    If foo is not defined it does not print the "{{ foo }}" to the page and it's just totally blank. The OP asked why does the "{{ foo }}" appear in it's literal form on the page? Defining foo is not the issue. I have the same problem right now doing the Step-by-Step tutorial and it doesn't work for a fresh install for html pages. Works fine for md. I suspect a missing config option that turns liquid on for html pages.
    – user96622
    Nov 10, 2022 at 0:46
  • Maybe that changed in the 8 years since I wrote that answer, I don't remember. IMO the OP actually asks why Jekyll doesn't render the value of foo correctly (quotes: "HTML Page Not Rendering Liquid", "but the page doesn't evaluate {{ foo }}"). Nov 10, 2022 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.