alabaster
alabaster copied to clipboard
Missing "Last updated on" timestamp in footer
The conf.py
generated by sphinx states the following:
# If not None, a 'Last updated on:' timestamp is inserted at every page
# bottom, using the given strftime format.
# The empty string is equivalent to '%b %d, %Y'.
html_last_updated_fmt = "%b %d, %Y"
The footer code at https://github.com/bitprophet/alabaster/blob/master/alabaster/layout.html#L44-L82 noticably lacks the {%- if last_updated %}
block from https://github.com/sphinx-doc/sphinx/blob/master/sphinx/themes/basic/layout.html#L182-L198. As a result, the "Last updated on:" part is missing from the footer:
This gist has the relevant code portions in one place.
Thanks for the report!
Feels like an oversight in the source themes...I see no Git diffs in our repo mentioning last_updated
, nor do I personally recall seeing it anywhere.
Would accept a PR that adds this in (or I might do it myself if it keeps bothering me)...specifically:
- [ ] May want to make this controlled by an opt-in Releases-level setting, so it doesn't unexpectedly appear for users not expecting it.
- However, I quickly checked, and the
{% if last_updated %}
is falsey unless one'sconf.py
containslast_updated_fmt
. So arguably this is a straight up display bug and not a "new/changed feature" that would need an opt-in. - Only counterpoint is that since the default Sphinx quickstart sets this to a non-empty value, users may be unaware of what it's supposed to do, and thus still be surprised when the new footer section appears on their next update.
- However, I quickly checked, and the
- [ ] At this point, with so many elements in the footer, we may want to see if we can generate more of it at the Python level, such that we can (in Python or the template) utilize
.join(' | ')
. Right now it's a mess of "did the previous section/s get displayed? Slap a pipe before printing our own stuff".
Where do you think the "Last updated on:" should be (i.e. left, right, in between other elements)?
As to the Sphinx default, I think the comments in conf.py
explains this well, so the default non-empty value shouldn't be a problem.
I think far-right looked fine when I tried it out temporarily. Open to opinions of course.
@bitprophet Is there any news about this? I'm using Alabaster for my CV website and would love to have a "last updated" footer.
any update?
As a quick workaround, I put this in my conf.py
:
from datetime import datetime
now = datetime.now()
project = 'Benjamin Lee'
copyright = str(now.year) + ', Benjamin Lee. Updated on ' + now.strftime("%B %d, %Y")
I use Sphinx sub-template https://www.sphinx-doc.org/en/master/templating.html#jinja-sphinx-templating-primer
in ./docs/_templates/layout.html
to extends layout.html
{% extends "!layout.html" %}
{%- block footer %}
<div class="footer">
{% if show_copyright %}©{{ copyright }}.{% endif %}
{% if theme_show_powered_by|lower == 'true' %}
{% if show_copyright %}|{% endif %}
Powered by <a href="http://sphinx-doc.org/">Sphinx {{ sphinx_version }}</a>
& <a href="https://github.com/bitprophet/alabaster">Alabaster {{ alabaster_version }}</a>
{% endif %}
{%- if last_updated %}
Last updated on {{ last_updated }}.
{%- endif %}
{%- if show_source and has_source and sourcename %}
{% if show_copyright or theme_show_powered_by %}|{% endif %}
<a href="{{ pathto('_sources/' + sourcename, true)|e }}"
rel="nofollow">{{ _('Page source') }}</a>
{%- endif %}
</div>
{%- endblock %}
So, I can rewrite the custom html.