diff --git a/docs/_templates/breadcrumbs.html b/docs/_templates/breadcrumbs.html
new file mode 100644
--- /dev/null
+++ b/docs/_templates/breadcrumbs.html
@@ -0,0 +1,16 @@
+{% extends "!breadcrumbs.html" %}
+
+{# Overrides RTD's default "View page source" link formatting, which
+ forces the full page name in the link; but we don't want it because
+ page names include the repo, eg. "swh-model/index".
+ The view_in_phabricator.py extension sets swh_source_url to
+ ".../source/swh-model/browse/master/docs/index"
+#}
+{%- block breadcrumbs_aside %}
+foo
+
+ {%- if hasdoc(pagename) and display_vcs_links %}
+ {{ _('View page source') }}
+ {% endif %}
+
+{%- endblock %}
diff --git a/swh/docs/sphinx/view_in_phabricator.py b/swh/docs/sphinx/view_in_phabricator.py
--- a/swh/docs/sphinx/view_in_phabricator.py
+++ b/swh/docs/sphinx/view_in_phabricator.py
@@ -16,15 +16,18 @@
return
elif pagename.startswith("swh-"):
# .rst from a package's docs/ directory
- repository = pagename.split("/", 1)[0]
- path = "docs/"
+ (repository, _, path) = pagename.partition("/")
else:
# .rst from swh-docs/docs/
repository = "swh-docs"
- path = "docs/"
- context[
- "source_url_prefix"
- ] = f"https://forge.softwareheritage.org/source/{repository}/browse/master/{path}"
+ path = pagename
+ source_url = (
+ f"https://forge.softwareheritage.org/source/{repository}"
+ f"/browse/master/docs/{path}"
+ )
+
+ # Set a variable that can be used by swh-docs/docs/_templates/breadcrumbs.html:
+ context["swh_source_url"] = source_url
def setup(app):