1
votes

I'm building a blog with Jekyll. For my design, I want to show part of the post content one side of the page and showing the rest of it on the other side of the page. I tried using the Jekyll post excerpt function, which kind of works but it still shows the post excerpt with the post's main content. So, it's showing up twice, which isn't what I want.

So, I basically want to separate the post content into 2 sections. Is that possible?

Example Markdown

---
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Cras facilisis, ligula id sodales dignissim, ligula felis maximus metus, 
nec malesuada odio ipsum ut mi. 
<!--excerpt -->

Quisque suscipit condimentum nisi sed ornare. 
Ut dictum id massa et finibus. 
Donec ut consequat massa. Aenean eget mauris quam. Sed ornare auctor sapien fringilla condimentum. 

HTML

    <div class="excerpt">
              <h3>Recipe</h3>
              {{ page.excerpt }}
            </div>
          </row>
        </div>
      </div>
      <div class="col-lg-6 col-sm-12 right split-cols">
          <div class="content">
            <header class="major">
            <h2>{{ page.title }}</h2>
            </header>
           {{ content }}
         </div>
1

1 Answers

1
votes

Yes it is possible, that is not the intended usage of the excerpt variable, but it can be achieved with Liquid filters, in this case the remove_first filter.

Removes only the first occurrence of a substring from a string.

So we have the page excerpt: {{ page.excerpt }}

And then in the other section the rest of the content filtering the first paragraph: {{ content|remove_first: page.excerpt }}.

The layout would look like:

<div class="excerpt">
    <h3>Recipe</h3>
    {{ page.excerpt }}
</div>
          </row>
  </div>
  </div>
  <div class="col-lg-6 col-sm-12 right split-cols">
      <div class="content">
          <header class="major">
              <h2>{{ page.title }}</h2>
          </header>
          {{content|remove_first: page.excerpt}}
      </div>

You should consider also putting the excerpt as a variable in the front matter and its usage would be simpler.