Trouble using html_last_updated_format

27 views
Skip to first unread message

sphinxuser124323

unread,
Apr 23, 2021, 4:12:36 AM4/23/21
to sphinx-users
I'd like to to use the "html_last_updated_fmt" option, but I'm having some trouble.

To test, I

- start a new project with sphinx-quickstart
- add this at the bottom of conf.py

    html_last_updated_fmt='%Y-%m-%d'"

- run "make html"
- open _build/html/index.html

I was expected to see a date generated somewhere in the footer, but I don't. Is it clear what I'm doing wrong?

I am using Sphinx 3.5.4

Matthias Geier

unread,
Apr 23, 2021, 4:53:20 AM4/23/21
to sphinx...@googlegroups.com
On Fri, Apr 23, 2021 at 10:12 AM sphinxuser124323 wrote:
>
> I'd like to to use the "html_last_updated_fmt" option, but I'm having some trouble.

If and where the date is displayed depends on the selected HTML theme.

The default "alabaster" theme seems to not display the date at all.

To fix this, you can create a custom template as shown in this issue:
https://github.com/bitprophet/alabaster/issues/93

Alternatively, you can choose a different HTML theme that displays the
date by default.

For a list of some themes, check out https://sphinx-themes.org/.

And if you want to show the "last updated" date for each HTML page
individually (instead of the same date for all pages), you can try my
little Sphinx extension
https://github.com/mgeier/sphinx-last-updated-by-git.

cheers,
Matthias

> To test, I
>
> - start a new project with sphinx-quickstart
> - add this at the bottom of conf.py
>
> html_last_updated_fmt='%Y-%m-%d'"
>
> - run "make html"
> - open _build/html/index.html
>
> I was expected to see a date generated somewhere in the footer, but I don't. Is it clear what I'm doing wrong?
>
> I am using Sphinx 3.5.4
>
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/7b28805d-e27e-40cf-80c3-1c8ba7039989n%40googlegroups.com.

Patrick Sanan

unread,
Apr 23, 2021, 5:50:09 AM4/23/21
to sphinx...@googlegroups.com
Thanks - it wasn't clear that the theme might not respect this setting, so this clears things up. Looks like some template has to actually do something with the "last_updated" value.

The theme I actually want to use is the pydata theme, which fortunately can be easily configured to give me my desired behavior.

For others who might stumble on this thread, these are the important things I added to conf.py :

    html_theme = 'pydata_sphinx_theme'

    html_theme_options = {
        "footer_items": ["copyright", "sphinx-version", "last-updated"],
    }

    html_last_updated_fmt='%Y-%m-%d'


Doc:
Reply all
Reply to author
Forward
0 new messages