8

I have this markdown code in a Markdown file. It has inline HTML.

---
layout: page
title: About This Website
permalink: /about/
---


This website is built with <i class="fa fa-heart" style="color: #EEAAAA"></i>, 
[Jekyll](https://jekyllrb.com/), [LESS](http://lesscss.org/), 
[Gulp](http://gulpjs.com/), and a series of other [NPM builders](http://gulpjs.com/plugins/).
It is hosted on [Github Pages](https://pages.github.com/).

But when I wrap the stuff below the front matter with a <div>, the markdown doesn't render. Even when I wrapped the opening and closing <div> tags with {% raw %}.

Why? Are there any workarounds? I'm using Jekyll 3.

2 Answers2

19

If you put your markdown inside an HTML block tag (e.g. div) than you have to allow markdown conversion (the default is off). In kramdown (the default for Jekyll 3) use the markdown="1" attribute. Example:

<div markdown="1">
This is a list:

- Item 1
- Item 2
- Item 3
</div>

PS: Good question. I have added your question to the Jekyll F.A.Q. Cheers.

Gerald Bauer
  • 306
  • 1
  • 4
  • Perfect! This allows me to have a collapsible Table of Contents within an HTML `
    ` tag. See my website [here](https://gabrielstaples.com/repairing-macbook/), where I do that. Thanks!
    – Gabriel Staples May 24 '23 at 22:54
  • This doesn't seem to work inside strikethrough `` tags. This: ``Strikethrough text: press Windows + D. Here is `some code`.
    `` doesn't properly render the `some code` part. :( Any idea how to fix this?
    – Gabriel Staples Jun 18 '23 at 21:58
3

That's exactly how the original Markdown implementation works:

Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style *emphasis* inside an HTML block.

Jekyll uses Redcarpet by default which behaves the same way. If you are running Jekyll yourself you might be able to create a custom Markdown processor to do what you want, but that won't work if you're using something like GitHub Pages for hosting.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257