Skip to content

Commit f934bb4

Browse files
Add robots.txt and structured data for SEO (#3610)
Add docs/robots.txt pointing crawlers to the sitemap. Add JSON-LD structured data to main.html: WebSite + Organization schema on the homepage (helps Google show sitelinks and knowledge panel), and BreadcrumbList schema on all other pages (helps Google show breadcrumb trails in search results). Also update the Twitter social link to x.com. AI Assistance: Claude Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 697600c commit f934bb4

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

docs/overrides/main.html

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,85 @@
55
<link rel="preload" href="{{ 'assets/fonts/GeistMono-Variable.woff2' | url }}" as="font" type="font/woff2" crossorigin>
66
<link rel="preload" href="{{ 'assets/fonts/GeistPixel-Square.woff2' | url }}" as="font" type="font/woff2" crossorigin>
77
<link rel="preload" href="{{ 'assets/fonts/GeistPixel-Circle.woff2' | url }}" as="font" type="font/woff2" crossorigin>
8+
{#
9+
Structured data (JSON-LD) for SEO.
10+
- Homepage gets WebSite + Organization schema (helps Google show sitelinks and knowledge panel).
11+
- All other pages get BreadcrumbList schema (helps Google show breadcrumb trails in results).
12+
Breadcrumb URLs are resolved via _find_leaf_url because MkDocs nav sections don't have
13+
their own URLs — we use the first descendant page's URL as a proxy.
14+
Dedup by title to collapse nav levels duplicated by plugins (e.g. the blog plugin nests
15+
"Blog" inside "Blog"). The current page is omitted when its title matches the last
16+
ancestor (e.g. /examples/ is both the "Examples" section index and the page itself).
17+
#}
18+
{% macro _find_leaf_url(nav_item) -%}
19+
{%- if nav_item.url -%}
20+
/{{ nav_item.url }}
21+
{%- elif nav_item.children -%}
22+
{{ _find_leaf_url(nav_item.children | first) }}
23+
{%- endif -%}
24+
{%- endmacro %}
25+
{% if page.is_homepage %}
26+
<script type="application/ld+json">
27+
{
28+
"@context": "https://schema.org",
29+
"@graph": [
30+
{
31+
"@type": "WebSite",
32+
"name": "dstack",
33+
"url": "https://dstack.ai/"
34+
},
35+
{
36+
"@type": "Organization",
37+
"name": "dstack",
38+
"url": "https://dstack.ai/",
39+
"logo": "https://dstack.ai/assets/images/dstack-logo-notext.svg",
40+
"sameAs": [
41+
"https://github.com/dstackai/dstack",
42+
"https://discord.gg/u8SmfwPpMd",
43+
"https://x.com/dstackai",
44+
"https://www.linkedin.com/company/dstackai"
45+
]
46+
}
47+
]
48+
}
49+
</script>
50+
{% elif page.ancestors | length > 0 %}
51+
<script type="application/ld+json">
52+
{
53+
"@context": "https://schema.org",
54+
"@type": "BreadcrumbList",
55+
"itemListElement": [
56+
{
57+
"@type": "ListItem",
58+
"position": 1,
59+
"name": "Home",
60+
"item": "https://dstack.ai/"
61+
}
62+
{%- set pos = namespace(val=2) -%}
63+
{%- set prev = namespace(title="") -%}
64+
{%- for ancestor in page.ancestors | reverse -%}
65+
{%- if ancestor.title != prev.title -%}
66+
,{
67+
"@type": "ListItem",
68+
"position": {{ pos.val }},
69+
"name": "{{ ancestor.title | e }}",
70+
"item": "https://dstack.ai{{ _find_leaf_url(ancestor) | trim }}"
71+
}
72+
{%- set pos.val = pos.val + 1 -%}
73+
{%- endif -%}
74+
{%- set prev.title = ancestor.title -%}
75+
{%- endfor -%}
76+
{%- if page.title != prev.title -%}
77+
,{
78+
"@type": "ListItem",
79+
"position": {{ pos.val }},
80+
"name": "{{ page.title | e }}"
81+
}
82+
{%- endif -%}
83+
]
84+
}
85+
</script>
86+
{% endif %}
887
{% endblock %}
988

1089
{% block container %}

docs/robots.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
User-agent: *
2+
Allow: /
3+
4+
Sitemap: https://dstack.ai/sitemap.xml

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ extra:
212212
- icon: /fontawesome/brands/discord
213213
link: https://discord.gg/u8SmfwPpMd
214214
- icon: /simple/x
215-
link: https://twitter.com/dstackai
215+
link: https://x.com/dstackai
216216
- icon: /fontawesome/brands/linkedin
217217
link: https://www.linkedin.com/company/dstackai
218218
status:

0 commit comments

Comments
 (0)