Converting my relatively basic personal website to Eleventy has shown me how challenging it is to build a static-site generator flexible enough to satisfy all the user cases and requirements. The great thing about Eleventy is being simultaneously opinionated by default and yet extremely flexible and customizable.
One area where everyone seems to have different requirements are reproducing blog post excerpts on the site’s home page. Here are my wants:
- By default, use the start of the content (up to a delimiter)
- Optionally, define the excerpt in the front matter configuration
- Markdown is parsed exactly the same as the original post
- Include images but allow custom styling on the home page
- Syntax highlighting
Here is how I implemented each of the requirements.