Reputation: 127
In Jekyll, I am trying to include a paragraph of "site information" that should go on a certain amount of pages in my website. The file structure of the certain information I am dealing with is a "team"folder->"_posts"folder-> then within the "_posts" folder is "site_information.md" and many other markdown files of pages that I want to include the "site_information.md" in. I do not want to use an includes statement on every single file in "_posts" folder if possible, so I want to make an includes statement in the "layout.html" file.
{% if page.page == "page" %}
{% include_relative site_information.md %}
{{content}}
{% endif %}}
The code above included the information I wanted, but it did not include it in markdown format.
{% if page.page == "page" %}
{% capture site_info %}{% include_relative site_information.md %}{% endcapture %}
{{site_info}}
{{content}}
{% endif %}
This code does not display the "site_information.md" information on the pages at all when using the capture tag.
{% if page.page == "page" %}
{% capture site_info %}{% include_relative site_information.md %}{% endcapture %}
{{site_info | markdownify}}
{{content}}
{% endif %}
This code gave me the error when using the markdownify tag:
Liquid Exception: undefined method `gsub' for nil:NilClass in _layouts/layout.html
Does anyone know how to fix this so I can use an includes statement in the layout to properly display a markdownified file on a number of web pages?
Upvotes: 2
Views: 1281
Reputation: 1291
Check that you are not trying to apply the markdownify
filter to empty text. You will get Liquid Exception: undefined method 'gsub' for nil:NilClass
if there is no text to markdownify.
Since you say that
This code does not display the "site_information.md" information on the pages at all when using the capture tag.
using the capture
method while it does not import any text will likely cause an error.
Upvotes: 1