minimal-mistakes: Related posts not shown
- This is a question about using the theme.
- I believe this to be a bug with the theme — not Jekyll, GitHub Pages or one of the bundled plugins.
- This is a feature request.
- I have updated all gems with
bundle update. - I have tested locally with
bundle exec jekyll build.
Environment informations
- Minimal Mistakes version: 4.0.1 (feature/theme-gem branch)
jekyllgem version: 3.2.1 (master branch)- Operating system: Mac OSX 10.11.6
Expected behavior
Related post should appear on every post as they are enabled by default in my _config.yml:
# Defaults
defaults:
# _posts
* scope:
path: ""
type: posts
values:
related: true
Steps to reproduce the behavior
- create a couple of posts
- enable related posts on
_config.yml
Additional information
If I insert the following code block (extracted from _layouts/single.html) in a post, the related posts are shown as expected:
{% if page.id and page.related and site.related_posts.size > 0 %}
<div class="page___related">
{% if site.data.ui-text[site.locale].related_label %}
<h4 class="page__related-title">{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}</h4>
{% endif %}
<div class="grid__wrapper">
{% for post in site.related_posts limit:3 %}
{% include archive-single.html type="grid" %}
{% endfor %}
</div>
</div>
{% endif %}
Any ideas? Thanks in advance for any help!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 27 (20 by maintainers)
Commits related to this issue
- changing 'related posts' to tag based outlined at: https://github.com/mmistakes/minimal-mistakes/issues/554#issuecomment-251993389 — committed to justinrummel/jr.com-mm by justinrummel 8 years ago
- Trying to move to tags based related items https://github.com/mmistakes/minimal-mistakes/issues/554 — committed to kimoppalfens/kimoppalfens.github.io by deleted user 8 years ago
- Replace `site.related_posts` with Liquid to display better matches based on tags - Close #554 — committed to mmistakes/minimal-mistakes by mmistakes 7 years ago
- Show 4 latest posts when `site.related_posts` is `nil` `site.related_posts` should return an array of latest posts when no related ones are found due to `lsi` being disabled (GitHub Page's doesn't su... — committed to kkunapuli/kkunapuli.github.io by mmistakes 7 years ago
- Replace `site.related_posts` with Liquid to display better matches based on tags - Close #554 — committed to adixchen/adrianmatei.com by mmistakes 7 years ago
- Show 4 latest posts when `site.related_posts` is `nil` `site.related_posts` should return an array of latest posts when no related ones are found due to `lsi` being disabled (GitHub Page's doesn't su... — committed to makaroniame/makaroniame-old.github.io by makaroniame 7 years ago
- Show 4 latest posts when `site.related_posts` is `nil` `site.related_posts` should return an array of latest posts when no related ones are found due to `lsi` being disabled (GitHub Page's doesn't su... — committed to jchwenger/jchwenger.github.io by mmistakes 7 years ago
- remove extra spaces (#554) Co-authored-by: Matt Wang <matt@matthewwang.me> — committed to koyumi0601/koyumi0601.github.io by MichelleBlanchette 2 years ago
- Show 4 latest posts when `site.related_posts` is `nil` `site.related_posts` should return an array of latest posts when no related ones are found due to `lsi` being disabled (GitHub Page's doesn't su... — committed to ovidus/ovidus.github.io by mmistakes 7 years ago
I came up with a way of showing “related posts” by like
post.tagsinstead of using the built insite.related_postsarray.The advantage here is you actually get a different set of related posts on each post instead of just the “most recent” posts that currently happens due to
LSIbeing disabled on GitHub Pages.Using this spaghetti code of Liquid in
_layouts/single.htmlwill display related posts that share the same tags as the current post. It will show 1-4 posts depending on how many matches it finds.Thoughts?
I’ve been against adding more configuration flags as they have many costs. In this case I don’t think it’s warranted as you can override the two files above as I have in the PR if you’re OK with slower builds.