- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Add lastmod datetime #733
Comments
@bjornerik I also want lastmod for my sitemap and am happy to implement it. Does the following sound reasonable?
|
Great!
|
@reactor10 need any more input on this? This would be very nice to have. |
Hi, is there any update on this ? Sometimes, I update an article to refresh the content or if something major happened (like Google Code hosting shutting down), and I'd like to have a Last Modified date to show. Will appreciate any feedback. |
@reactor10 may know. |
Sorry guys. I got stuck with the implementation as I couldn't work out where best to put the timestamp. Here's a branch I was working on: master...reactor10:byron-lastmod My question @bep: When the sitemap is generated I cannot access the full original path in order to do an |
@reactor10 for many reasons it should be a field on Node, |
Is the scope of this issue only to add |
The scope is:
|
@reactor10 any progress on this? |
@bep I took @reactor10's code as a base and made some modifications, to get lastmod working on Page. Here's the branch master...jbrodriguez:jbrodriguez-lastmod |
Sorry that my communication has been poor (nonexistent), thanks for Byron Williams byron@112percent.com On Tue, 12 May 2015, at 14:42, Juan B. Rodriguez wrote:
Links: |
@jbrodriguez it doesn't look like what I specified. It's not like what I say must be right all the time, but I said something about:
|
@bep Let me check, I seem to have a general idea on how to put it in Node. One question, eventually, from a page template (let's say _default/single.html), one would refer to Lastmod by
|
This should work on both The distinction here is confusing in Hugo. Page = content pages, Node = list pages. In technical terms, the Node struct is embedded in Page (this is a very cool Go construct that encourages composition (in contrast to inheritance)). So, if you look at But since Node (home page, list pages) has no physical file connected to it, the value for Date (and Lastmod) must be derived (last post) for the list pages -- but fetched from front matter for the content pages. |
@bep That's a very cool language feature, didn't know about it. Here's a branch that follows your specs master...jbrodriguez:jbrodriguez-lastmod-3 If Lastmod is set in front matter, it picks it up; if not set, it assigns Date to Lastmod. The only issue I see here is that Date == "file creation date", whereas file modification date feels like a better fit. Please let me know your comments. |
@jbrodriguez this looks very good. Just two comments:
Finally - if you could also change the sitemap.xml template in /tpl/template_embedded.go from .Date => .Lastmod I would be perfectly happy. That was the reason I opened up this issue in the first place. |
No, drop the s.Info.LastCreated for now -- but make sure that s.Info.LastChange gets the Lastmod value. |
Ok, I've made the changes (same branch master...jbrodriguez:jbrodriguez-lastmod-3) Two comments: 1 - There are other internal templates that should probably be modified as well:
2 - This code
t.pages is a WeightedPages, so it's sorted by user's definition (defaults to Date?). But adding Lastmod means t.pages[0] not necessarily has the "latest" Lastmod. If that's the case, perhaps we should scan t.pages or sort a copy of t.pages, to find the latest Lastmod. Let me know how you see this. |
@jbrodriguez - this looks good. Create a pull request and I will pull it in. The rest of your comments are good, but let us take those in #1141 |
Set sitemap.xml <lastmod> field to Lastmod. See #733
Have the user docs been updated with this change? I don't see anything on the template variables page. |
Okay cool. It's not clear to me how to order by that field though. I checked the docs here. From here, I got to this bit of code.
which yields this exception when I attempt to build.
which led me to #1330 -- I guess I will wait for v 0.15 |
Create new field in Node Update Page to look for lastmod field in the front matter. If not present, then assign Date to Lastmod Update Site, to assign a value to Lastmod (based on the same logic used for Date) Fixes gohugoio#733
Set sitemap.xml <lastmod> field to Lastmod. See gohugoio#733
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
There is date (default sort) publishdate (when it is published). #726 want expirydate.
I want lastmod -- to be used in sitemap.xml etc. I often make changes to my content, but I do not want to bring it to the top just to notify Google about these changes.
It should by default be set to the vale of date, but should be overridable in frontmatter. Maybe "hugo new" should add this as well?
The text was updated successfully, but these errors were encountered: