DEV Community

Andrei Valentin Popa
Andrei Valentin Popa

Posted on

How to add hard breaks to your Astro Blog

In my opinion, soft breaks are absolutely useless, would you write your content in markdown and not add space between paragraphs?

Besides that some content has to be displayed with hard breaks and it's annoying to add a <br> or other escape character.

Astro uses remark to render markdown so if you want to add hard breaks you have to install the remark-breaks plugin.

npm install remark-breaks
Enter fullscreen mode Exit fullscreen mode

Then modify astro.config.mjs and enable the plugin.

import remarkBreaks from 'remark-breaks';

export default defineConfig({
  markdown: { remarkPlugins: [remarkBreaks] },
});
Enter fullscreen mode Exit fullscreen mode

Top comments (0)