Skip to content

Commit 49b85d2

Browse files
Add last updated for document (#11164)
## Summary ![image](https://github.com/user-attachments/assets/75431f9f-debe-435d-a02e-d216be7a3a01) ![image](https://github.com/user-attachments/assets/2d1b895e-4878-410e-90ff-ff8e932cbf24) Display the last document update time, excluding any automatically generated parts of the document, while ensuring that Google can accurately read and recognize the webpage's time. Note that I do not have permission to update ``requirements-insiders.txt`` Google time info * https://developers.google.com/search/blog/2019/03/help-google-search-know-best-date-for * https://developers.google.com/search/docs/appearance/structured-data/article#amp Similar #11162 Closes #11148 ## Test Plan uvx --with-requirements docs/requirements.txt -- mkdocs serve -f mkdocs.public.yml --strict ![image](https://github.com/user-attachments/assets/6e8cd609-2e60-489c-97cc-fb28aa3204e0) The correct format is actually ``2024-08-08T22:01:08Z``, but Google Search happens to be lenient and accepts this format. ![image](https://github.com/user-attachments/assets/2ec8ce98-49ea-403b-bbd2-3d0d5630a562)
1 parent 73e9928 commit 49b85d2

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

.github/workflows/publish-docs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- uses: actions/checkout@v4
2727
with:
2828
ref: ${{ inputs.ref }}
29+
fetch-depth: 0
2930

3031
- uses: actions/setup-python@v5
3132
with:

docs/.overrides/main.html

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<meta name="robots" content="index,follow"/>
2222
<script type="application/ld+json">
2323
{
24+
{% if page and page.meta.git_revision_date_localized_raw_iso_datetime %}
25+
"datePublished": "{{ page.meta.git_revision_date_localized_raw_iso_datetime }}Z",
26+
"dateModified": "{{ page.meta.git_revision_date_localized_raw_iso_datetime }}Z",
27+
{% endif %}
2428
"@context": "https://schema.org",
2529
"@type": "WebSite",
2630
"name": "Astral Docs",

docs/requirements.in

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ mdformat>=0.7.17
66
mdformat-mkdocs>=2.0.4
77
mdformat-admon>=2.0.2
88
mkdocs-redirects>=1.2.2
9+
mkdocs-git-revision-date-localized-plugin>=1.3.0

docs/requirements.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# This file was autogenerated by uv via the following command:
22
# uv pip compile docs/requirements.in -o docs/requirements.txt --universal -p 3.12
33
babel==2.15.0
4-
# via mkdocs-material
4+
# via
5+
# mkdocs-git-revision-date-localized-plugin
6+
# mkdocs-material
57
black==24.4.2
68
# via -r docs/requirements.in
79
certifi==2024.7.4
@@ -19,6 +21,10 @@ colorama==0.4.6
1921
# mkdocs-material
2022
ghp-import==2.1.0
2123
# via mkdocs
24+
gitdb==4.0.12
25+
# via gitpython
26+
gitpython==3.1.44
27+
# via mkdocs-git-revision-date-localized-plugin
2228
idna==3.7
2329
# via requests
2430
jinja2==3.1.4
@@ -72,10 +78,13 @@ mergedeep==1.3.4
7278
mkdocs==1.6.0
7379
# via
7480
# -r docs/requirements.in
81+
# mkdocs-git-revision-date-localized-plugin
7582
# mkdocs-material
7683
# mkdocs-redirects
7784
mkdocs-get-deps==0.2.0
7885
# via mkdocs
86+
mkdocs-git-revision-date-localized-plugin==1.3.0
87+
# via -r docs/requirements.in
7988
mkdocs-material==9.5.29
8089
# via -r docs/requirements.in
8190
mkdocs-material-extensions==1.3.1
@@ -106,6 +115,8 @@ pymdown-extensions==10.8.1
106115
# via mkdocs-material
107116
python-dateutil==2.9.0.post0
108117
# via ghp-import
118+
pytz==2025.1
119+
# via mkdocs-git-revision-date-localized-plugin
109120
pyyaml==6.0.1
110121
# via
111122
# mkdocs
@@ -120,6 +131,8 @@ requests==2.32.3
120131
# via mkdocs-material
121132
six==1.16.0
122133
# via python-dateutil
134+
smmap==5.0.2
135+
# via gitdb
123136
uc-micro-py==1.0.3
124137
# via linkify-it-py
125138
urllib3==2.2.2

mkdocs.public.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ INHERIT: mkdocs.template.yml
22
# Omit the `typeset` plugin which is only available in the Insiders version.
33
plugins:
44
- search
5+
- git-revision-date-localized:
6+
timezone: UTC # It can only be in UTC unless the ISO time can include timezone.
57
validation:
68
anchors: warn
79
watch:

0 commit comments

Comments
 (0)