diff --git a/layouts/partials/sidebar-v2.html b/layouts/partials/sidebar-v2.html
index c886bbfb..cc45b812 100644
--- a/layouts/partials/sidebar-v2.html
+++ b/layouts/partials/sidebar-v2.html
@@ -19,8 +19,13 @@
{{ range $group := . }}
{{ range $product := $group.products }}
{{ if not $product.extUrl }}
- {{ $escaped := replace $product.url "/" "\\/" }}
- {{ $pattern := printf "/%s(|$)" $escaped }}
+
+ {{ $escaped := strings.TrimPrefix "/" $product.url }}
+ {{ $escaped = strings.TrimSuffix "/" $escaped }}
+
+ {{ $escaped = replace $escaped "/" "\\/" }}
+ {{ $pattern := printf "/(%s)/" $escaped }}
+
{{ if strings.FindRE $pattern $normalizedPath }}
{{ $currentProductTitle = $product.title }}
{{ end }}