Hard linebreaks not working in md

As I want hard linebreaks between paragraphs in my markdown files, I added [blackfriday] extensions = ["hardLineBreak"] to config.toml. But, there are no linebreaks rendered in the html. I restarted hugo server and rebuild the site, but no effect.

Did you add it to the configuration file or the front matter of your markdown?

  extensions = ["hardLineBreak"]

The docs are a bit confusing - the override should be in the markdown.

It’s possible to set some options for Markdown rendering in a content’s front matter as an override to the BlackFriday rendering options set in your project configuration.

Does this mean one needs to add this option to the frontmatter? Adding it to config.toml is not enough? If so, it seems a bit weird adding config stuff to content files…
How would one write this in yaml?

Yes, you must add it to the front matter. I only use TOML, so I can’t help with the YAML equivalent.

Hmm, is there a reason we cannot just have a global setting? (Haven’t figured out yet how to express this setting in YAML.

Try https://gohugo.io/commands/hugo_convert/

@artelse This worked fine for me in my config.toml

    extensions = [hardLineBreak]

This should work across the entire site, although @michael_henderson is right that anything in your front matter will override anything you set in your global/site config. Cheers.

1 Like

You’re right, it does. I’m not sure why it didn’t seem to earlier. Thanks :slightly_smiling:

1 Like

@rdwatters that’s what I would expect, but in my case it refuses to insert line breaks. I also tried your variation to omit "" around the setting, but that is not allowed of course. So yeah… any ideas how to kick Hugo into expected behavior?

I can’t reproduce this behavior @artelse. Can you tell me a bit more about your machine, Hugo version, etc.

(And ignore the lack of punctuation from my previous comment; I need to stop responding on my phone.)

@rdwatters Hugo Static Site Generator v0.19 darwin/amd64 BuildDate: 2017-02-27T12:36:32+01:00 on macOS 10.12.3. Line endings are 0x0A standard LF. Any other info that can be helpful?

@rdwatters @michael_henderson It appears to be a CSS issue. The CSS framework I use collapsed all margins and paddings on the p element to zero. Thanks for the help!

Cool. Did you check your inspector? The hard line breaks should related to inserting <br/> independent of the CSS…just double checking.

For future users, would you mind please adding [SOLVED] to the thread title? Cheers.

Oh, <br/>s have not been inserted… back to the problem then…

I’m still not able to recreate this issue. Do you happen to have a repo I can look at for local testing please?

Note that the blackfriday config can live in both site config and page front matter (page settings will override site). I did it this way before we had multi language, as I needed parts of my site with angled quotes (Norwegian).

@rdwatters no repo, am working locally. It shouldn’t matter I am working in my own theme stuff does it? config.toml should get the linebreaks working. One other thing, I have Hugo binary not globally installed.

No it shouldn’t. I only ask because I can’t recreate your issue locally and I too am working with Hugo on macOS. I wanted to see about pulling your repo and running it locally for debugging purposes. I feel like there is something else missing here…

Interestingly, when I run hugo --verbose the first line doesn’t show what config file is loaded:
INFO 2017/03/20 23:44:23 Using config file:
One would think it doesn’t see the config file, but I can use site variables like .Site.Title and they are rendered just fine. So indeed something is wrong here.

I’m on macOS, too. It’s working in both the front matter and the config.toml file.

<p>first line.<br />
second line.<br />
fourth line.</p>