docsy icon indicating copy to clipboard operation
docsy copied to clipboard

Is there a way to auto-generate a date, based on last edit?

Open amirootyet opened this issue 3 years ago • 5 comments

Context: Our Docsy instance is hosted on an Azure Static Web App connected to a Github repo. Build happens via Github Actions.

Issue: For every page on Docsy, only the overall last modification to the repo, along with the commit message, is shown. On localhost, we can see the Last Modified for each page separately when we navigate to individual pages, but when hosted on Azure Static Web App, using the workflow I described above, it only shows the overall repo modification date on every page.

  1. How do we get a Last Modified date per page (as we see on localhost when testing locally)?
  2. How do we move this further up on the page, next to the "X minute read" counter?

Our pages are type: docs and not blog so we also noticed that frontmatter date: xx etc. doesn't work for pages. Is there a reliable way to auto-generate last modified dates for each individual page in Docsy to track when a documentation page was last updated?

amirootyet avatar Jun 23 '22 19:06 amirootyet

Hi there,

  1. Hmm, not sure what's happening there. The Docsy "last modified" feature uses the Hugo LastMod variable, which uses .GitInfo.AuthorDate. This should give you the last modified (in Github) details for each individual page. Might be something to ask the Hugo forum: https://discourse.gohugo.io/
  2. Moving the last modified info up the page should be straightforward enough - though it's not configurable in the template so you'd need to make your own copy of the default page layout and move this line:
{{ partial "page-meta-lastmod.html" . }}

up under the reading time (you can also make your own copy of the last modified partial if you want to tweak the look of it).

LisaFC avatar Jun 30 '22 21:06 LisaFC

Hi @amirootyet can you please assign this issue to me?

ShlokJswl avatar Jan 23 '23 14:01 ShlokJswl

Hi @ShlokJswl we don't assign issues in this project. If you would like to contribute please check out our Contributing Guidelines.

emckean avatar Jan 23 '23 23:01 emckean

I know I am a bit late to the party, but if someone come's here in the future:

To display the last modified date without editing the last modified partial you need to set enableGitInfo to true as well as set the github_repo in your config file. Alternatively, you can edit the last modified partial (/layouts/partials/page-meta-lastmod.html) to remove this condition.

If you only want to override the git author date on some pages, you can change the order of precedence in your config file using

[frontmatter]
lastmod = ['lastmod', ':git', 'modified', 'date', 'publishdate', 'pubdate', 'published']

and then set the lastmod value in your page's front matter. See https://gohugo.io/getting-started/configuration/#configure-dates for more information.

adlerzei avatar Feb 02 '24 07:02 adlerzei

One other thing that I've just learned (might be obvious to others): for the gitinfo to work properly, you need to have full clone of the repo where you are building the docs. So for example if you just do a shallow clone in your github action build, all the lastmod dates will point to the latest commit.

fekete-robert avatar Feb 02 '24 08:02 fekete-robert