diff --git a/lib/resources/script.js b/lib/resources/script.js
index f5dba29a78..e8fbb6f4cc 100644
--- a/lib/resources/script.js
+++ b/lib/resources/script.js
@@ -100,7 +100,12 @@ function initSearch(name) {
'constructor' : 4
};
- var baseHref = $('body').data('base-href');
+ var baseHref = '';
+ if (!$('body').data('using-base-href')) {
+ // If dartdoc did not add a base-href tag, we will need to add the relative
+ // path ourselves.
+ baseHref = $('body').data('base-href');
+ }
function findMatches(q) {
var allMatches = []; // list of matches
diff --git a/lib/templates/html/_head.html b/lib/templates/html/_head.html
index 44b8600764..20682fa81a 100644
--- a/lib/templates/html/_head.html
+++ b/lib/templates/html/_head.html
@@ -31,7 +31,8 @@
{{! We don't use