gjtorikian / jekyll-last-modified-at

A Jekyll plugin to show the last_modified_at time of a post.
MIT License
241 stars 38 forks source link

Strange problem on Jekyll 4.0.0 version #74

Open zhandosweb opened 4 years ago

zhandosweb commented 4 years ago

Hello!

Please, let me ask one question. I faced a strange problem.

I installed a plugin. Then I go to my post.md, and write: {% last_modified_at %}.

And there I get the error: Liquid Exception: No such file or directory - etc... Here is a screenshot of the problem: http://i.imgur.com/v3EgzGe.png

Here is my code: http://i.imgur.com/hJ5vdEW.png. But, if I put before {% last_modified_at %} any text, there is no error, screenshot: http://i.imgur.com/bDaK7i9.png

Why I faced with this problem? And how I can resolve it?

Sorry for bad English, I'm still learning. Believe, that you understand me.

gjtorikian commented 4 years ago

Hello. Do you have the gem installed in your Gemfile, like this?

It is very strange that the error asks for #excerpt, because that file does not exist in this plugin at all. If you remove {% last_modified_at %}, is the error still there?

emmahsax commented 4 years ago

I'm getting a very similar error. Gemfile:

gem 'jekyll-last-modified-at', '~> 1.2.1', group: :jekyll_plugins

_config.yml:

plugins:
  - jekyll-last-modified-at

HTML:

<footer>
  Last modified at {% last_modified_at %}.
</footer>

Error:

Liquid Exception: No such file or directory - /path/to/repository/repo_name/.html does not exist! in /_layouts/default.html

If I change the HTML to be:

<footer>
  Last modified at {{ page.last_modified_at }}.
</footer>

the error disappears, and it renders the date correctly.

Or, if I move the code to somewhere not in the footer (in a markdown file instead), it also renders the page last modified date:

---
title: Page
---

Last modified at {% last_modified_at %}.

renders: image

My end goal is to just show the date the entire site was last modified at, to eventually be used in an Atom RSS feed.

I am using Jekyll 3.8.6.


UPDATE: I think I misunderstood what this gem does. It gets the modified date for each page, not the whole site. I ended up writing this, which loops through all of the pages and gathers the last_modified_at into an array, and then sorts to find the most recent:

{% assign modified_dates = "" | split: ',' %}
{% assign pages = site.html_pages | where_exp:'doc','doc.sitemap != false' | where_exp:'doc','doc.url != "/404.html"' %}
{% for page in pages %}
  {% if page.last_modified_at %}
    {% assign modified_dates = modified_dates | push: page.last_modified_at %}
  {% endif %}
{% endfor %}

{{ modified_dates | sort | last }}