Multiple Markdown-text-sections

I’d like to get multiple divs containing Markdown in a single post for a multi-column-post-layout.

e.g. in -->

title ="post1"

#Headline 1
Text 1

#Headline 2
Text 2

in layout -->

< div >
{{.Content[1]}} --> renders Headline 1 and Text 1
< /div >
< div >
{{.Content[2]}} --> renders Headline 2 and Text 2
< \div >

Well i could wrap parts before/after < hr > with javascript… but that wouldn’t be very nice…

Unfortunately i couldn’t find anything about this “basic?” use-case or i was searching for the wrong things.


:slight_smile: AK

support is buggy… AND i want the text to break at a specific point. So its more two texts…
:slight_smile: AK

There is an open issue or two about content sections on GitHub, but I wouldn’t be too hopeful about that getting solved anytime soon.

In the meantime …

  • You solve this by being creative with shortcodes with your divs.
  • Or maybe put the columns in to a markdown table …


I think I’d need to see what you’re trying to do, but if the content in one section is only headings, you could get clever with the front matter as well. Or you could do something with .Next or . Prev maybe…?

You could use the split template function. Just insert a custom delimiter in the content files at each point where the content should continue in the next column.

Your code would look as follows. I have not tested it but you should get at least a foundation. <split> is our custom delimiter.

{{ $cols := split .Content "<split>" }}

{{ range $cols }}
   <div class="content-column">
   {{ . }}
{{ end }}

@digitalcraftsman That is awesome and something I never would have thought of.

@digitalcraftsman Wow, that seems to be thing i was looking for! I’ll going to try it soon and report back. Thanks!! :slight_smile:


I found this post when searching for a a way to place an image next to text (in a two colomn way), and it helpt me achieve this by creating a partial like this:

{{ $cols := split .RawContent "||" }}

{{ range $cols }}
   <div class="content-column">
   {{ . | markdownify }}
{{ end }}

thanks @digitalcraftsman


Trying to do the same thing now, do you have a link to your blog so I can take a look at the implementation? Thanks!