diff --git a/lib/plugins/html/htmlBuilder.js b/lib/plugins/html/htmlBuilder.js index fbc7e4f3cd..561d50fd8c 100644 --- a/lib/plugins/html/htmlBuilder.js +++ b/lib/plugins/html/htmlBuilder.js @@ -300,6 +300,12 @@ export class HTMLBuilder { ) : []; let rootPath = this.storageManager.rootPathFromUrl(url, daurlAlias); + const summaryPagePath = + this.context.resultUrls.relativeSummaryPageUrl(url, daurlAlias) + + 'index.html'; + const baseHref = options.useSameDir + ? undefined + : rootPath + summaryPagePath; let data = { daurl: url, daurlAlias, @@ -322,6 +328,7 @@ export class HTMLBuilder { get, markdown: markdown, rootPath, + baseHref, resultUrls: this.context.resultUrls, assetsPath: assetsBaseURL || rootPath, sitespeedioURL: options.html.homeurl, @@ -370,6 +377,12 @@ export class HTMLBuilder { run => !!get(pageInfo.data, [run.id, 'run']) ); let rootPath = this.storageManager.rootPathFromUrl(url, daurlAlias); + const runPagePath = + this.context.resultUrls.relativeSummaryPageUrl(url, daurlAlias) + + `${iteration}.html`; + const baseHref = options.useSameDir + ? undefined + : rootPath + runPagePath; let data = { daurl: url, daurlAlias, @@ -395,6 +408,7 @@ export class HTMLBuilder { get, markdown: markdown, rootPath, + baseHref, resultUrls: this.context.resultUrls, assetsPath: assetsBaseURL || rootPath, sitespeedioURL: options.html.homeurl, diff --git a/lib/plugins/html/templates/layout.pug b/lib/plugins/html/templates/layout.pug index 5c45cb2634..9df37f649c 100644 --- a/lib/plugins/html/templates/layout.pug +++ b/lib/plugins/html/templates/layout.pug @@ -3,6 +3,8 @@ html(lang='en') head meta(charset='utf-8') meta(name='viewport', content='width=device-width, initial-scale=1') + if baseHref + base(href=baseHref) title= pageTitle meta(name='description', content=pageDescription) meta(name='robots', content='noindex')