Skip to content

Commit 34850e3

Browse files
committed
Add sitemap and expand and fix page metadata
1 parent 070d818 commit 34850e3

3 files changed

Lines changed: 64 additions & 14 deletions

File tree

src/_config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ launch_buttons:
4141
jupyterhub_url: ""
4242

4343
sphinx:
44+
extra_extensions:
45+
- sphinx_sitemap
46+
- sphinx-last-updated-by-git
4447
config:
4548
templates_path:
4649
- _templates
4750
html_baseurl: https://ua-libraries-research-data-services.github.io/UALIB_ScholarlyAPI_Cookbook/
51+
html_context:
52+
html_baseurl: https://ua-libraries-research-data-services.github.io/UALIB_ScholarlyAPI_Cookbook/
53+
sitemap_url_scheme: "{link}"

src/_templates/layout.html

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,55 @@
33
{%- block extrahead %}
44
{{ super() }}
55

6+
{% set site_name = "Scholarly API Cookbook" %}
7+
{% set base = (html_baseurl or "https://ua-libraries-research-data-services.github.io/UALIB_ScholarlyAPI_Cookbook/") %}
8+
{% set page_url = base ~ pagename ~ ('' if pagename.endswith('.html') else '.html') %}
9+
10+
{# Prefer page description; fallback to a global site description #}
11+
{% set site_desc = "Practical tutorials and examples for working with scholarly APIs, research metadata, and reproducible data workflows using Python and R." %}
12+
{% set page_desc = meta.get("description") if meta is defined else None %}
13+
{% set desc = page_desc or site_desc %}
14+
15+
{# Allow per-page overrides for social #}
16+
{% set og_title = (meta.get("og:title") if meta is defined else None) or (title|striptags) %}
17+
{% set og_type = (meta.get("og:type") if meta is defined else None) or "website" %}
18+
{% set og_image = (meta.get("og:image") if meta is defined else None) %}
19+
20+
{% set tw_card = (meta.get("twitter:card") if meta is defined else None) or "summary" %}
21+
{% set tw_image = (meta.get("twitter:image") if meta is defined else None) or og_image %}
22+
23+
<!-- Canonical Link -->
24+
<link rel="canonical" href="{{ page_url }}" />
25+
26+
<!-- Open Graph -->
27+
<meta property="og:site_name" content="{{ site_name }}" />
28+
<meta property="og:title" content="{{ og_title }}" />
29+
<meta property="og:description" content="{{ desc }}" />
30+
<meta property="og:type" content="{{ og_type }}" />
31+
<meta property="og:url" content="{{ page_url }}" />
32+
33+
<!-- Twitter Card -->
34+
<meta name="twitter:card" content="{{ tw_card }}" />
35+
<meta name="twitter:title" content="{{ og_title }}" />
36+
<meta name="twitter:description" content="{{ desc }}" />
37+
38+
<!-- LD+JSON -->
639
<script type="application/ld+json">
740
{
841
"@context": "https://schema.org",
942
"@graph": [
1043
{
1144
"@type": "Organization",
12-
"@id": "{{ html_baseurl }}#org-ua",
45+
"@id": "{{ base }}#org-ua",
1346
"name": "The University of Alabama",
14-
"alternateName": ["UA"],
47+
"alternateName": ["UA", "Bama"],
1548
"url": "https://www.ua.edu/",
1649
"sameAs": [
1750
"https://en.wikipedia.org/wiki/University_of_Alabama"
18-
]
51+
],
1952
"subOrganization": {
2053
"@type": "Organization",
21-
"@id": "{{ html_baseurl }}#org-ua-libraries",
54+
"@id": "{{ base }}#org-ua-libraries",
2255
"name": "The University of Alabama Libraries",
2356
"alternateName": [
2457
"UA Libraries",
@@ -30,14 +63,14 @@
3063
"subOrganization": [
3164
{
3265
"@type": "Organization",
33-
"@id": "{{ html_baseurl }}#org-rds",
66+
"@id": "{{ base }}#org-rds",
3467
"name": "Research Data Services",
3568
"alternateName": ["RDS"],
3669
"url": "https://guides.lib.ua.edu/rds/"
3770
},
3871
{
3972
"@type": "Organization",
40-
"@id": "{{ html_baseurl }}#org-rcs",
73+
"@id": "{{ base }}#org-rcs",
4174
"name": "Research Computing Services",
4275
"alternateName": ["RCS"],
4376
"url": "https://guides.lib.ua.edu/RCS/"
@@ -47,24 +80,33 @@
4780
},
4881
{
4982
"@type": "WebSite",
50-
"@id": "{{ html_baseurl }}#website",
83+
"@id": "{{ base }}#website",
5184
"name": "University of Alabama Libraries Scholarly API Cookbook",
52-
"url": "{{ html_baseurl }}",
85+
"alternateName": [
86+
"UA Libraries Scholarly API Cookbook",
87+
"University Libraries Scholarly API Cookbook",
88+
"UALIB Scholarly API Cookbook",
89+
"Scholarly API Cookbook",
90+
"Scholarly API Guide"
91+
],
92+
"description": "{{ site_desc }}",
93+
"url": "{{ base }}",
5394
"publisher": {
54-
"@id": "{{ html_baseurl }}#org-ua-libraries"
95+
"@id": "{{ base }}#org-ua-libraries"
5596
},
5697
"logo": {
5798
"@type": "ImageObject",
58-
"url": "{{ html_baseurl }}images/script-a-icon.png"
99+
"url": "{{ base }}images/script-a-icon.png"
59100
}
60101
},
61102
{
62103
"@type": "WebPage",
63-
"@id": {{ (html_baseurl ~ pathto(pagename, 1) ~ "#webpage") | tojson }},
104+
"@id": {{ page_url ~ "#webpage" | tojson }},
64105
"name": {{ title | striptags | tojson }},
65-
"url": {{ (html_baseurl ~ pathto(pagename, 1)) | tojson }},
66-
"isPartOf": { "@id": "{{html_baseurl}}#website" },
67-
"publisher": { "@id": "{{html_baseurl}}#org-ua-libraries" }
106+
"url": {{ page_url | to_json }},
107+
"dateModified": "{{ last_updated | tojson }}",
108+
"isPartOf": { "@id": "{{ base }}#website" },
109+
"publisher": { "@id": "{{ base }}#org-ua-libraries" }
68110
}
69111
]
70112
}

src/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
jupyter-book<2
22
matplotlib
33
numpy
4+
sphinx-sitemap
5+
sphinx-last-updated-by-git

0 commit comments

Comments
 (0)