From 6fd0d94611f6d618137f164421d9de18d731e710 Mon Sep 17 00:00:00 2001
From: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
Date: Wed, 8 Jul 2026 22:39:12 +0800
Subject: [PATCH] feat: support non-root baseurl
This adds support for hosting on a non-root sub-path (with
--baseurl` flag), such as when deploying on a GitHub fork
Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
---
_data/topnav.yml | 2 +-
_includes/footer.html | 2 +-
_includes/head.html | 4 +---
_includes/sidebar_menu_list_items.liquid | 17 +++++++++++------
_includes/topnav.html | 4 ++--
index.html | 2 +-
6 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/_data/topnav.yml b/_data/topnav.yml
index d15fe66be..4e40f2121 100644
--- a/_data/topnav.yml
+++ b/_data/topnav.yml
@@ -11,7 +11,7 @@ topnav_dropdowns:
- title: View
folderitems:
- title: LoopBack Overview
- url: /
+ url: /doc/
- title: LoopBack 4
url: /doc/en/lb4/
- title: LoopBack 3.x
diff --git a/_includes/footer.html b/_includes/footer.html
index 521fec78f..7120d7d8f 100755
--- a/_includes/footer.html
+++ b/_includes/footer.html
@@ -5,7 +5,7 @@
{% if page.last_updated %}
Page last updated: {{page.last_updated}}
{% endif %} Site last generated: {{ site.time | date: "%b %-d, %Y" }}
diff --git a/_includes/head.html b/_includes/head.html
index 5b2121051..8f459eedb 100644
--- a/_includes/head.html
+++ b/_includes/head.html
@@ -1,6 +1,4 @@
-{% if jekyll.environment == "production" %}
- {% assign base = site.url %}
-{% endif %}
+{% assign base = site.baseurl | prepend: site.url %}
diff --git a/_includes/sidebar_menu_list_items.liquid b/_includes/sidebar_menu_list_items.liquid
index b69d6ac50..f13e6e903 100644
--- a/_includes/sidebar_menu_list_items.liquid
+++ b/_includes/sidebar_menu_list_items.liquid
@@ -5,15 +5,20 @@
{% if item.children.size > 0 %} {% endif %}
{% if item.url %}
- {{ item.title }}
+ {% assign itemUrl = item.url %}
+ {% assign itemUrlFirstChar = item.url | slice: 0 == '/' %}
+ {% if itemUrlFirstChar == "/" "%}
+ {% assign itemUrl = itemUrl | prepend: site.baseurl %}
+ {% endif %}
+ {{ item.title }}
{% else %}
{{ item.title }}
{% endif %}
- {% if item.children.size > 0 %}
-
- {% include sidebar_menu_list_items.liquid menuitems=item.children %}
-
- {% endif %}
+ {% if item.children.size > 0 %}
+
+ {% include sidebar_menu_list_items.liquid menuitems=item.children %}
+
+ {% endif %}
{% endif %}{% comment %} /"if web" {% endcomment %}
diff --git a/_includes/topnav.html b/_includes/topnav.html
index 7ab991941..8949ea4a4 100644
--- a/_includes/topnav.html
+++ b/_includes/topnav.html
@@ -40,9 +40,9 @@
{% if folderitem.external_url %}
{{folderitem.title}}
{% elsif page.url contains folderitem.url and folderitem.title != 'LoopBack Overview' %}
- {{folderitem.title}}
+ {{folderitem.title}}
{% else %}
- {{folderitem.title}}
+ {{folderitem.title}}
{% endif %}
{% endfor %}
diff --git a/index.html b/index.html
index cebb360aa..0e57e5d29 100644
--- a/index.html
+++ b/index.html
@@ -438,7 +438,7 @@ Ready to build amazing things?
-
+