No line breaks in titles that are line-wrapped in markdown

I like to start new lines after 80 characters when editing any file, including my markdown files, so that I don’t have to scroll horizontally in my editor (I also think a lot of people like to work like this, so this may not be an edge case at all).

This works well with Hugo and markdown for most things, like there is no <br />
or <p> in the HTML Hugo puts out, as long as I don’t put two empty spaces at the end in the markdown.
However, this does not seems to work for headings. Instead, the heading will end where I put a new line (without empty spaces behind it) and the next line will be rendered as “normal” text.

What I want hugo to do for me: I sometimes have headings that exceed 80 characters and I would like to break them in markdown after 80 characters, hugo should still output the HTML in one line, leaving the heading intact, without any line breaks.

Is there a way to do this? Or am I doing it wrong?

Many editors allow for soft line breaks: The line appears to be broken, but there’s neither a line feed nor a newline character. And that works with headlines, too.

What you see with a heading being terminated with a newline is normal Markdown behavior, I think – the # concerns only the same physical line it is on.

In case of h1 or h2 you can use setext headings instead. Like this:

word1
word2
===

word1
word2
---
2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.