Trying to include date page updated


First post - so please be gentle! and apologies if I’m asking in the wrong place…

I’m playing with a gh pages site using Jekyll and the Leap Day theme, and I’m trying to figure out how i can include “Page Last Updated: date…” in the footer.

I’ve sort of worked out that I need to include some liquid in the footer of the default.html template (been messing about with other stuff). Problem is I can’t figure out or find any information about what liquid to include.

Any help/advice gratefully received

Andy B.

1 Like

Welcome @Andy-ABTec,

What about the variable site.time?:

<footer><p>{{ site.time }}</p></footer>

site.time isn’t the same as last modified, it’s just the current time when Jekyll builds your site.

You’ll likely want to set the DateTime of your post/page with something like last_modified_at: in its YAML front matter. If you can install Jekyll plugins you can use this one and it’ll set the last modified datetimes for you.Then you can access it via your layouts or includes with {{ page.last_modified_at }}.

I suggest calling it the variable last_modified_at because many of Jekyll’s official plugins like jekyll-feed and jekyll-sitemap support it.

Hi guys, and thanks for the quick replies.

I’d already found googling earlier but couldnt get it to work.

Either I misinterpreted the installation steps (more than likely) or the plugin doesn’t seem to like themed pages on GitHub…

I presume to install it locally (WSL) I just run “gem install jekyll-last-modified-at” and also add it to the plugins list in “_config.yml”

Apologies if I’m being thick, I’ve only been playing with Jekyll for a few days.

3rd party plugins don’t work with GitHub Pages so that’s likely the issue. They only allow a select few due to security reasons.

You can use the plugin but it’ll have to be if you self host elsewhere or use something like Travis CI to build your Jekyll site and push the contents of _site back to GitHub to host.

You can still use last_modified_at, you’ll just need to manually update that timestamp in your post/page’s YAML Front Matter. Depending on the text editor you use there might be options. For example I use Sublime Text and Visual Studio Code, and both have extensions/macros for quickly updating a timestamp.

That answers that then!
Many thanks for your time…

Happy Christmas!

Andy B.