diff --git a/README.md b/README.md index 6409eb5..0e3d3b0 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ To include navigation in your site's masthead: Be sure to start your `url`s with a `/`. -## Pagination +#### Pagination To paginate your posts, add the following line to your site's `Gemfile`: @@ -71,6 +71,41 @@ paginate_path: "/page/:num/" You can set the `paginate` and `paginate_path` settings to whatever best suits you. +#### Excerpts + +To show [excerpts](https://jekyllrb.com/docs/posts/#post-excerpts) of your blog posts on the home page, add the following settings to your site's `_config.yml` file: + +``` +show_excerpts: true +``` + +By default, excerpts that have more than 140 characters will be truncated to 20 words. In order to override the number of words you'd like to show for your excerpts, add the following setting to your site's `_config.yml` file: + +``` +excerpt_length: 20 +``` + +To disable excerpt truncation entirely, simply set `excerpt_length` to `0` in your site's `_config.yml` file, like so: + +``` +excerpt_length: 0 +``` + +If you do this, the theme will still respect Jekyll's `excerpt_separator` feature as [described in the Jekyll documentation](https://jekyllrb.com/docs/posts/#post-excerpts). + + +#### Title-less Posts + +If you want to publish posts that don't have a title, add the following setting to the [front matter](https://jekyllrb.com/docs/frontmatter/) of the post: + +``` +title: "" +``` + +When you do this, the home page will display a truncated [excerpt](https://jekyllrb.com/docs/posts/#post-excerpts) of the first paragraph of your post. + +Note that setting `excerpt_length` in your site's `_config.yml` file will set the length of _all_ excerpts, regardless of whether the post has a title or not. For posts with a title, the excerpt will appear under the title and slightly lighter. For title-less posts, the excerpt will appear as if it were a title. + ### Post Layout A sparsely decorated layout designed to present long-form writing in a manner that's pleasing to read. diff --git a/_config.yml b/_config.yml index b1869b8..a889e37 100644 --- a/_config.yml +++ b/_config.yml @@ -37,4 +37,5 @@ markdown: kramdown # - vendor/gems/ # - vendor/ruby/ -show_excerpts: true \ No newline at end of file +show_excerpts: true +excerpt_length: 0 \ No newline at end of file diff --git a/_includes/post-excerpt.html b/_includes/post-excerpt.html index ded85f3..2a49178 100644 --- a/_includes/post-excerpt.html +++ b/_includes/post-excerpt.html @@ -2,12 +2,18 @@ {{ post.excerpt | replace: "

", "" | replace: "

", "" }} {% endcapture %} -{% assign excerpt_length = excerpt | size %} +{% if site.excerpt_length %} + {% assign excerpt_length = site.excerpt_length %} +{% else %} + {% assign excerpt_length = 20 %} +{% endif %} - - {% if excerpt_length > 140 %} - {{ excerpt | truncatewords: 20, '…' }} +{% assign excerpt_size = excerpt | size %} + + + {% if excerpt_size > 140 and excerpt_length > 0 %} + {{ excerpt | truncatewords: excerpt_length, '…' }} {% else %} {{ excerpt }} {% endif %} - \ No newline at end of file + \ No newline at end of file