2
votes

I'm writing a blog with Jekyll. I know that jekyll has the excerpt_separator which can be used to specify the end of an excerpt like

This is a blog post, click to see more than this
<!-- more -->
This is not in excerpt

However, I'd like to start each of my blog posts with a quote, but not include that quote in the excerpt. Something like

>   “There are two ways of constructing a software design: One way is to make it
>   so simple that there are obviously no deficiencies and the other way is to
>   make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare

<!-- begin_excerpt -->
This is the excerpt
<!-- end_excerpt -->

Not part of the excerpt.

So far I've been unable to find evidence that this is supported.
How might I go about accomplishing this?

2

2 Answers

2
votes

I found an alternate approach that works and shouldn't break expected behavior. I found if you moved the quote to the front matter and altering your layout, you can have the excerpt ignore the quote.

The sample post:

---
title: Test of Quote Post
layout: quotepost
categories: Random
comments: false
quote: |
    Hack the Planet!  
    Hack the Planet!
---
A sample post preceded by a quote.

Section of the layout:

{% if page.quote %}
  <p class="lead">{{ page.quote | markdownify }}</p> 
{% endif %}     
<p class="lead">{{ content }}</p>

This works because the quote is no longer part of the posts content. However the posts layout will add the quote to the pages layout ahead of the posts content. You can even give quotes their own style properties this way. This is also how you would add features to a page that are not part of the content(like comments).

Notes: You will have to add a double space after each line of the quote if you want them to be on separate lines. Also if you want to have the entire posts content displayed on another page, you will have to manually include the quote if desired.

1
votes

Unfortunately, Jekyll doesn't by default support a way to specify the start of an excerpt.

One possible way to get around this issue would be to use the excerpt variable in Jekyll's front matter and just write the required text directly to it and then display the value of the page.excerpt variable in the page content.

It is a bit messy and breaks the page content up but it will work.

---
excerpt: 'This is the excerpt'
---

>   “There are two ways of constructing a software design: One way is to make it
>   so simple that there are obviously no deficiencies and the other way is to
>   make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare

{{ page.excerpt }} // This is the excerpt

Not part of the excerpt.