-
Notifications
You must be signed in to change notification settings - Fork 25.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Related posts not shown #554
Comments
Link to a repo so I can troubleshoot? Most likely it's a content or config problem on your end. |
it's a kinda private repo, but here it is the |
Config looks fine. Could be content or something else but since I can't see that to test hard to say. |
ok, possibly it's something wrong somewhere... I'll review everything again. |
Also just noticed you're using the What happens if you pull down the latest stable release and drop in the contents of your Since it's working fine on the demo site I have a suspicion there's something going on with the theme in |
Yes, I'm testing the
I copied the posts from the minimal-mistakes/example/_posts/ (again the |
Did some testing of my own and there are some posts in the demo site that don't show related posts even though they should. Adding this for a post with related
and this for ones without
I don't really know how Jekyll determines what is related and what isn't but for that appears to be where the bug or problem is. I suspect it's content related but not sure why that would matter. Sites like @JHabdas's appears to work just fine so it doesn't appear to be the theme's fault. Where it gets even stranger is only the most 4 recent posts on the demo site show related posts. I took the most recent post (which is showing related posts), changed the date so it became the last post in the list, and the related posts disappeared. Thought maybe I'm really stumped here. Only thing I can think of would be to not use |
Scroll down on any post on https://habd.as to see the related posts feature and feel free to inspect my blog source code: https://github.com/jhabdas/habd.as. Good luck! |
@JHabdas I'm stumped why it's working fine for you but not the MM's demo site. I wrote the damn thing and I can't figure out what's going wrong 😅 It's really strange. After the 4th most recent post they stop showing. I thought maybe it was working for you because you're using a newer Jekyll gem, but looks like it's the older GitHub Pages one. And in @fa-ribeiro's case their using the latest Jekyll off of So strange! |
ROFL Might be worth leaving this open and see if anyone else is having issues besides @fa-ribeiro. Also, @mmistakes when you're ready to come to the dark side I'd love to work together to port this theme to Hugo. |
@JHabdas That's what I was thinking. If it's a widespread issue and not something to do with a weird content edge-case I'm surprised I hadn't heard about yet. RE: Hugo. I've looked at it and considered switching my personal site over just because it takes so long to build. Everyone always says it builds faster than Jekyll when you have a lot of posts but it would be a crap ton of work for me to rebuild just to test that. So I haven't. PR's like this give me faith Jekyll's build speed will improve. I've made a lot of improvements pulling out anything that isn't strictly for converting Not to mention I didn't really care for the template syntax. It's close enough to Liquid sure, but it just looks ugly to me. |
Hi guys, Maybe unrelated but I have the same issue in my gh-pages branch I forked from the master about 5-6 days ago. I have the following in my
but related posts is not showing on any of my posts, see https://icicimov.github.io/blog/ I was under impression this should be working by default but maybe I'm missing something. I'm not sure how the plugin/feature works ie is it parsing the posts body to find a match based on some words or is just picking up 4 random posts etc. Probably I'm just missing something, some non-minimal mistake :-( Thanks, |
I believe there may be a bug in Jekyll core and how it handles related posts. The theme is using this to output 4 related posts, which is wrapped in a conditional that only shows the module when there are related posts and the feature is enabled.
When I remove For example the 4 most recent posts show related posts fine, but when you hit say the 5th post there are no related posts shown. The There's probably another way to limit the amount of related posts shown that I'll investigate to get around the issue. As far as what |
I came up with a way of showing "related posts" by like 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 Using this spaghetti code of Liquid in {% comment %}<!-- show posts by related tags when `related: true` -->{% endcomment %}
{% if page.related %}
{% assign n_posts = 0 %}
{% for post in site.posts %}
{% if post.id == page.id %}{% continue %}{% endif %}
{% for this_tag in page.tags %}
{% if post.tags contains this_tag %}
{% if n_posts == 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">
{% endif %}
{% include archive-single.html type="grid" %}
{% assign n_posts = n_posts | plus: 1 %}
{% break %}
{% endif %}
{% endfor %}
{% if n_posts > 3 %}{% break %}{% endif %}
{% endfor %}
{% if n_posts > 0 %}
</div>
</div>
{% endif %}
{% endif %} Thoughts? |
@mmistakes , thanks for the code it works for me, tried and applied to my site. Matching by tags looks like right direction to go in terms of logic about finding related posts if you ask me. At the end, just wanted to say thanks for this awesome theme! |
@icicimov Great! Yeah I think related posts by tags does a better job of conveying "related posts" than whatever basic method the default uses. |
Trying to convert my site to the Gem version of MM. Was this ever added to the Gem version or should I copy my old single.html to the _layouts/ folder? |
@justinrummel would love to hear more about your experience once you make the leap! |
@justinrummel No. This is still open as I haven't found a fix. If you're using the gem version remove all local _layouts, _includes, and _sass folders and files. Unless of course you want them to override the ones bundled in the gem. |
@mmistakes and @JHabdas the migration is complete. Wasn't as bad as I thought except for all the images moving from /images/ to /asset/images/. Took me a while to figure out what was doing what (inserting the default vs. my .md files forcing a path). Thank goodness for ~/mm-gem-repo/> perl -p -i -e 's/(^ image: )/ image: \/assets\/images\//g' _posts/*
~/mm-gem-repo/> perl -p -i -e 's/(^ overlay_image: )/ overlay_image: \/assets\/images\//g' _posts/*
~/mm-gem-repo/> perl -p -i -e 's/(^ teaser: )/ teaser: \/assets\/images\//g' _posts/* If there was something still wrong, I would search the origin HTML to see if I could find something unique and then search the repo for that value: ~/mm-gem-repo/> find . -type f -exec grep -e 'mySearchItem' \{\} \; -print From there I had to find what didn't function or look right. I inserted Instagram images on the main page, added .css for "fifth" and "sixth" for large amount of photosets pointing to flickr, added Lunr search functionality, and finally this section for related items. I prefer the searching on tags vs. what is default right now. I guess I'll leave the single.html until something permanent takes it place. My slimmed down repo is: |
While researching HTTPS testing via
I can confirm it gives me different results than a list of 10 most recent posts, but still don't think it is perfect. If you try the --lsi option, be sure to install |
I've always used LSI but pretty sure it's disabled on sites hosted with GitHub Pages. The best solution ice found is using a related post plugin that improves on the one built into Jekyll. But that's sadly not an option for the vast amount of people hosting the theme on GH. |
I came up with a different solution that uses a post tags to compare against and show related posts that way. It can be tested from PR #978 or by copying these two files to your |
`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 support it). This works around that bug by showing the 4 latest posts to populate the "You May Also Enjoy" module when enabled with `related: true`. Fixes mmistakes#554 Related: mmistakes#978 mmistakes#1022
…sed on tags - Close mmistakes#554
It looks like this was closed without ever implementing tag-based related posts - was that intentional? I'm dealing with this now, and it seems that it would be pretty trivial to do, but I'm not sure why you didn't. If this is something that can be rolled into the gem, then I won't bother now, otherwise I'll override it. |
My pull request made build times worse. That is why it wasn’t merged. I wasn’t comfortable degrading build times for users... especially those with a lot of posts. |
Would putting it as a configurable option, for example, |
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. |
`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 support it). This works around that bug by showing the 4 latest posts to populate the "You May Also Enjoy" module when enabled with `related: true`. Fixes mmistakes#554 Related: mmistakes#978 mmistakes#1022
`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 support it). This works around that bug by showing the 4 latest posts to populate the "You May Also Enjoy" module when enabled with `related: true`. Fixes mmistakes#554 Related: mmistakes#978 mmistakes#1022
Co-authored-by: Matt Wang <[email protected]>
Here's a big improvement over all the other solutions I found: https://karmanivero.us/blog/related-posts-with-minimal-mistakes/ |
bundle update
.bundle exec jekyll build
.Environment informations
jekyll
gem version: 3.2.1 (master branch)Expected behavior
Related post should appear on every post as they are enabled by default in my
_config.yml
:Steps to reproduce the behavior
_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:Any ideas?
Thanks in advance for any help!
The text was updated successfully, but these errors were encountered: