Search code examples
jekyllliquid

Q: Jekyll - 2 sections displaying nearly same content


I have two very similar sections on a jekyll website.

The displayed content change for only some words or resources.

I handle this using 3 files:

  • One markdown content without Front Matter. This file content the text with if conditions:
# Mardown Content
Here is more info about: 
{% if page.section == 'sectionA' %}
[Something About Setion A](/sectionA/something)
{% elsif page.section == "sectionB" %}
[Something About Setion B](/sectionB/somethingelse)
{% endif %}
  • Two markdown files with front matter including the content
---
layout: myTemplate
section: sectionA/B
title: something
---
{% include content.md %}

I used to have those 3 files in the same directory using {% include_relative content.md %}. This way seems better because the files were in the same directory and the _include folder do not mix up content and html templates.

But my config of jekyll builds also a page for the content file displaying an html page.

Is there a way to prevent serving this html content?

Do you know a better way to handle this?


Solution

  • In _config.yml add :

    exclude:
     - content.md
    

    This will instruct Jekyll not to process content.md.

    Note : I don't get why you cannot put content.md in the _includes folder.