diff --git a/ckan/templates/layout_base.html b/ckan/templates/layout_base.html
index 0e2518c9967..b5ce868a0cd 100644
--- a/ckan/templates/layout_base.html
+++ b/ckan/templates/layout_base.html
@@ -243,7 +243,9 @@
// Declare js array from Python string
${['\'%s\', '%s for s in config.get('ckan.plugins','').split(' ')]}
];
- CKAN.SITE_URL = '${g.site_url}';
+ CKAN.SITE_URL = '${h.url('/')}';
+ // later use will add offsets with leading '/' so ensure no trailing slash
+ CKAN.SITE_URL = CKAN.SITE_URL.replace(/\/$/, '');
$(document).ready(function() {
var ckan_user = $.cookie("ckan_display_name");
if (ckan_user) {