Situation

Use code block (`code`) to display code when creating MD file. However, in the case of html and javascript code, the execution result of the code is output instead of the code.

---
layout: default
---
<ul class="posts-list">  
  
  <h4>Posts in Solve the html javasciprt code display error in md (markdown) file </h4>

Solution

Wrap it in { % raw % } code { % endraw % } codeblock.

Note: { And % should be used without spaces.

---
layout: default
---
<ul class="posts-list">  
  {% assign category = page.category | default: page.title %}
  <h4>Posts in {{ category }} </h4>