2
votes

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 }}.

1
Just to be sure, you're visiting the url through jekyll server right?romainberger
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?sunnyrjuneja

1 Answers

5
votes

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 }}