Closed jamesbraza closed 11 months ago
Hi @jamesbraza,
If you dont supply Lastmod
in posts' front matter, it will not show Modified
section.
Le me know if you were able to resolve.
For me, my front matter is (it has no Lastmod
):
---
title: "Foo"
date: 2023-04-23
draft: false
tags: ["article"]
---
Even explicitly adding Lastmod: false
did not turn off the "Modified" text. What am I missing? Any tips?
Hi again,
It seems to be very strange indeed.
In this post, I have supplied Lastmod
as follows.
title: "Typography"
slug : 'typography'
date: 2023-07-22T14:36:33+05:30
draft: false
featuredImg: ""
description : 'Integer lobortis vulputate mauris quis maximus. Vestibulum ac eros porttitor, auctor sem sed, tincidunt nulla. In sit amet tincidunt ex.'
tags:
- Demo
- Typography
Lastmod : 2023-08-15T15:36:33+05:30
I get :
Now if I remove:
title: "Typography"
slug : 'typography'
date: 2023-07-22T14:36:33+05:30
draft: false
featuredImg: ""
description : 'Integer lobortis vulputate mauris quis maximus. Vestibulum ac eros porttitor, auctor sem sed, tincidunt nulla. In sit amet tincidunt ex.'
tags:
- Demo
- Typography
I don't get the Lastmod section.
Please re-check your config if everything is properly formatted and/or do a full recheck on all the files if Lastmod is given somewhere.
Lol I am trying to figure it out, it's got me stumped too
One question, elsewhere I see .Params.tags
, but with .Lastmod
it's not using Params
. Why is it not .Params.Lastmod
?
I think .Lastmod
is a Hugo-global parameter that is always present
Ahh I see. I have enableGitInfo = true
in my config, which seems to globally enable .Lastmod
: https://github.com/1bl4z3r/hermit-V2/blob/1ad173d2ab6817d7ca033b28b507df5ba8e08be6/hugo.toml#L32
Any chance you can add in some capability to disable enableGitInfo
opting pages into .Lastmod
?
To properly explain your previous query,
There were some changes in Hugo where while defining custom local page variables (i.e. Page Variables whose scope is within the page itself), we can ignore .Params as it is implied that we are trying to fetch local page variables. You can definitely put in .Params.Lastmod
and the output would be exactly the same.
It was something to differentiate from inbuilt Page variables and custom Page variables. I am still unsure if we can access custom Page variables from other pages or not.
[EDIT]
We can absolutely access custom page variables from outside the page by using .Page.Params.[VARIABLE]
.
[EDIT 2] StackOverflow guy explains it better than me. https://stackoverflow.com/questions/70808386/using-page-variables-in-hugo
For enableGitInfo
, I am quite unsure how to properly implement this, so that it would not break the core functionality.
If .GitInfo
is enabled, we want .Lastmod
to be prefilled with the data. It is just extending from core function of .GitInfo
. However, if you want to enable .GitInfo
and have different date for .Lastmod
, there needs to be some value juggling to do.
Ohkay, here's a big brain moment.
What can be done is in each page a new Page Variable could be setup, whose only job in the world is to enable/disable [Modified:] section. It won't matter if .Lastmod should be shown or not for the post.
If .GitInfo
is true and .LastmodEnabler
is false, Modified section is not shown
If .GitInfo
is true and .LastmodEnabler
is true, Modified section is shown, Date fetched from git
If .GitInfo
is false and .LastmodEnabler
is true, Modified section is shown, with each page having a dedicated .Lastmod
If .GitInfo
is false and .LastmodEnabler
is false, Modified section is not shown
Let me know if you want this to be implemented.
I like what you propose! It:
Sounds good to me
Cool cool cool It shouldn't take me more than 1 business day to implement.
Okay sound good, ahha no need to provide business days here, it's FOSS babyyyy
Implemented. Same is updated on #last-modified-date
If IgnoreLastmod
is not provided or IgnoreLastmod=false
, then:
enableGitInfo = true
, then Git Hash will be shown in [...]
after Date.enableGitInfo = false
, then:
Lastmod
is not provided or Lastmod
has same value as Date
, error will be thrown.Lastmod
is provided or Lastmod
is different from Date
, value of Lastmod
will be displayed in [...]
after Date.Closing this issue. Re-open if required.
Not Fixed yet
This is finalfinalfinal. As usual, details updated in #last-modified-date
If ShowLastmod:true
:
enableGitInfo = true
, then Git Hash will be shown in [...]
after Date.enableGitInfo = false
, then:
Lastmod
is not provided or Lastmod
has same value as Date
, error will be thrown.Lastmod
is provided or Lastmod
is different from Date
, value of Lastmod
will be displayed in [...]
after Date.If ShowLastmod
is not provided. User response defaults to false. It is equivalent to providing ShowLastmod:false
.
And I was wrong.
Any Page Variable should be called via .Page.Params. if you ignore .Page or .Site, .
by default has Global scope.
.Lastmod is inbuilt Hugo Variable attached with GitInfo, hence it has global scope.
I see this is part of
single.html
in v1.0.2, where it has anif .Lastmod
conditional.Any chance we can expose a new config parameter to turn off this behavior? I like the default "creation only" timestamp. Alternately, maybe a post front matter parameter could be useful too