Moacir
Moacir

Reputation: 65

How to serve raw Markdown in Jekyll/GHpages?

I would like my GitHub pages website (long story) to serve a few unrendered Markdown pages.

If I leave the .md file, even without metadata, in the root level of the repository, it gets converted to html. I want it to stay Markdown.

If I add the .md file to exclude in _config.yml, then it doesn't show up at all in GHpages.

I can get this to work in vanilla Jekyll using keep_files, but I suspect it's not possible to get GHpages to see those files, as they're inside _site, which gets ignored by Git.

Upvotes: 0

Views: 731

Answers (1)

juzraai
juzraai

Reputation: 5953

You can display plain text in Markdown, so one option is to wrap the contents of your .md file inside <pre> tags:

<pre>
# Your header

Your paragraph, etc.
</pre>

Or, if you don't want to modify your Markdown files:

  1. Place your .md file inside _includes directory, e.g. _includes/raw.md
  2. Create a page anywhere (and doesn't matter if extension is .md or .html), and use include, inside <pre> tags:

---
---
<pre>{% include raw.md %}</pre>

(The path after include is relative to _includes directory.)

This will also display your Markdown file unrendered.

Upvotes: 2

Related Questions