Skip to content

Commit f532f34

Browse files
authored
Merge pull request #15 from microsoft/seo/pw-infra-structured-data
docs(seo): PyTorch-Wildlife structured-data + social + self-hosted assets parity
2 parents 242c3e3 + 2f13d57 commit f532f34

5 files changed

Lines changed: 104 additions & 2 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ on:
66
- main
77
paths:
88
- 'docs/**'
9+
- 'overrides/**'
910
- 'mkdocs.yml'
1011
- 'docs-requirements.txt'
12+
workflow_dispatch:
1113

1214
jobs:
1315
deploy:
@@ -16,6 +18,8 @@ jobs:
1618
contents: write
1719
steps:
1820
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
1923

2024
- uses: actions/setup-python@v5
2125
with:

docs-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ mkdocs-material-extensions
55
pymdown-extensions
66
mkdocstrings
77
mkdocstrings-python
8+
mkdocs-callouts
9+
mkdocs-git-revision-date-localized-plugin

docs/assets/cat.png

295 KB
Loading

mkdocs.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ copyright: Copyright (c) 2023 Microsoft Corporation
99

1010
theme:
1111
name: material
12-
favicon: https://zenodo.org/records/15376499/files/cat.png
13-
logo: https://zenodo.org/records/15376499/files/cat.png
12+
custom_dir: overrides
13+
favicon: assets/cat.png
14+
logo: assets/cat.png
1415
icon:
1516
menu: material/menu
1617
alternate: material/translate
@@ -99,6 +100,11 @@ markdown_extensions:
99100
pygments_lang_class: true
100101

101102
plugins:
103+
- callouts
102104
- search
103105
- meta
104106
- tags
107+
- git-revision-date-localized:
108+
type: date
109+
enable_creation_date: true
110+
fallback_to_build_date: true

overrides/main.html

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{% extends "base.html" %}
2+
3+
{#
4+
Theme override for SEO structured data and a clean homepage <title>.
5+
Schema is gated on page.file.src_path. Homepage uses a connected @graph
6+
(WebSite + SoftwareSourceCode + Organization) per schema review.
7+
#}
8+
9+
{% block htmltitle %}
10+
{%- if page and page.file and page.file.src_path == "index.md" -%}
11+
<title>PyTorch-Wildlife: Open-Source Conservation Deep Learning Framework | Microsoft AI for Good</title>
12+
{%- else -%}
13+
{{ super() }}
14+
{%- endif -%}
15+
{% endblock %}
16+
17+
{% block extrahead %}
18+
{{ super() }}
19+
20+
{%- set social_title = page.meta.title if page and page.meta and page.meta.title else (page.title if page and page.title else config.site_name) -%}
21+
{%- set social_desc = page.meta.description if page and page.meta and page.meta.description else config.site_description -%}
22+
<meta property="og:type" content="website">
23+
<meta property="og:site_name" content="{{ config.site_name }}">
24+
<meta property="og:title" content="{{ social_title | striptags }}">
25+
<meta property="og:description" content="{{ social_desc | striptags }}">
26+
<meta property="og:url" content="{{ page.canonical_url if page and page.canonical_url else config.site_url }}">
27+
<meta property="og:image" content="{{ config.site_url }}assets/cat.png">
28+
<meta property="og:image:alt" content="PyTorch-Wildlife: open-source conservation deep learning framework by Microsoft AI for Good Lab">
29+
<meta name="twitter:card" content="summary_large_image">
30+
<meta name="twitter:title" content="{{ social_title | striptags }}">
31+
<meta name="twitter:description" content="{{ social_desc | striptags }}">
32+
<meta name="twitter:image" content="{{ config.site_url }}assets/cat.png">
33+
<meta name="twitter:image:alt" content="PyTorch-Wildlife: open-source conservation deep learning framework by Microsoft AI for Good Lab">
34+
{#- TODO(design): swap in a 1200x630 banner + add og:image:width/height when delivered -#}
35+
36+
{%- if page and page.file and page.file.src_path == "index.md" %}
37+
<script type="application/ld+json">
38+
{{- {
39+
"@context": "https://schema.org",
40+
"@graph": [
41+
{
42+
"@type": "WebSite",
43+
"@id": config.site_url ~ "#website",
44+
"url": config.site_url,
45+
"name": config.site_name,
46+
"inLanguage": "en",
47+
"description": config.site_description,
48+
"publisher": { "@id": "https://www.microsoft.com/en-us/ai/ai-for-good#organization" }
49+
},
50+
{
51+
"@type": "SoftwareSourceCode",
52+
"@id": config.site_url ~ "#software",
53+
"name": config.site_name,
54+
"description": config.site_description,
55+
"url": config.site_url,
56+
"mainEntityOfPage": config.site_url,
57+
"codeRepository": config.repo_url,
58+
"programmingLanguage": "Python",
59+
"runtimePlatform": "Python",
60+
"isAccessibleForFree": true,
61+
"license": "https://github.com/microsoft/Pytorch-Wildlife/blob/main/LICENSE",
62+
"creator": { "@id": "https://www.microsoft.com/en-us/ai/ai-for-good#organization" },
63+
"maintainer": { "@id": "https://www.microsoft.com/en-us/ai/ai-for-good#organization" },
64+
"sameAs": ["https://github.com/microsoft/Pytorch-Wildlife", "https://pypi.org/project/PytorchWildlife/", "https://arxiv.org/abs/2405.12930"],
65+
"keywords": ["PyTorch-Wildlife", "wildlife AI framework", "conservation deep learning framework", "wildlife model zoo", "camera trap detection", "species classification"]
66+
},
67+
{
68+
"@type": "Organization",
69+
"@id": "https://www.microsoft.com/en-us/ai/ai-for-good#organization",
70+
"name": "Microsoft AI for Good Lab",
71+
"url": "https://www.microsoft.com/en-us/ai/ai-for-good"
72+
}
73+
]
74+
} | tojson -}}
75+
</script>
76+
{%- endif %}
77+
78+
{%- if page and page.file and page.file.src_path != "index.md" and page.canonical_url %}
79+
<script type="application/ld+json">
80+
{{- {
81+
"@context": "https://schema.org",
82+
"@type": "BreadcrumbList",
83+
"itemListElement": [
84+
{ "@type": "ListItem", "position": 1, "name": "PyTorch-Wildlife", "item": config.site_url },
85+
{ "@type": "ListItem", "position": 2, "name": page.title | striptags, "item": page.canonical_url }
86+
]
87+
} | tojson -}}
88+
</script>
89+
{%- endif %}
90+
{% endblock %}

0 commit comments

Comments
 (0)