Search code examples
markdownjekyll

Jekyll begin *and* end excerpt separators


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?


Solution

  • 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.