Search code examples
markdowncontentful

Adding HTML elements and class attributes to Contentful CMS Markdown content?


We need to have some basic <div> and <div class="someclass"> This is our text </div> type info in our content delivered via Contentful API. Basically something to denote sections and classes.

Is it possible to add this using Contentful Editor?


Solution

  • In order to do that, you need to use a markdown parser which supports that. If you take a look at Kramdown for Ruby (for instance), you'll see it has a way of defining classes by using specific syntax. You just need to check whether the parser you're using has this kind of feature, and the required syntax 🙂