From 1668b10ff7922375f97d5f0c0bf9ec8551254903 Mon Sep 17 00:00:00 2001
From: Sherlock Xu <65327072+Sherlock113@users.noreply.github.com>
Date: Mon, 11 Nov 2024 16:32:59 +0800
Subject: [PATCH] docs: Add doc canonical link (#5076)

* Add doc canonical link

Signed-off-by: Sherlock113 <sherlockxu07@gmail.com>

* ci: auto fixes from pre-commit.ci

For more information, see https://pre-commit.ci

---------

Signed-off-by: Sherlock113 <sherlockxu07@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
---
 docs/source/conf.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/docs/source/conf.py b/docs/source/conf.py
index 034105bd9cc..19795e9824b 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -1,4 +1,5 @@
 import importlib.metadata
+import os
 from datetime import datetime
 
 # -- Project information -----------------------------------------------------
@@ -156,6 +157,9 @@
     "dark_logo": "img/logo-dark.svg",
 }
 
+# Set canonical URL from readthedocs domain
+html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/")
+
 html_title = "BentoML"
 html_static_path = ["_static"]
 html_css_files = [