From c9a17982cf298a62e26688c914cdeda6ce59d0ef Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 14 Sep 2016 17:08:26 +0100 Subject: [PATCH] Add canonical url tag and don't include query string --- services/web/app/coffee/infrastructure/ExpressLocals.coffee | 4 +++- services/web/app/views/layout.jade | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index d3b9d9a24b..b57556a42d 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -123,7 +123,9 @@ module.exports = (app, webRouter, apiRouter)-> res.locals.translate = (key, vars = {}) -> vars.appName = Settings.appName req.i18n.translate(key, vars) - res.locals.currentUrl = req.originalUrl + # Don't include the query string parameters, otherwise Google + # treats ?nocdn=true as the canonical version + res.locals.currentUrl = Url.parse(req.originalUrl).pathname next() webRouter.use (req, res, next)-> diff --git a/services/web/app/views/layout.jade b/services/web/app/views/layout.jade index 88fe4187fe..7d986e5abf 100644 --- a/services/web/app/views/layout.jade +++ b/services/web/app/views/layout.jade @@ -21,6 +21,7 @@ html(itemscope, itemtype='http://schema.org/Product') link(rel="icon", href="/favicon.ico") link(rel='stylesheet', href=buildCssPath('/style.css')) + link(rel="canonical", href=settings.siteUrl+currentUrl) if settings.i18n.subdomainLang each subdomainDetails in settings.i18n.subdomainLang if !subdomainDetails.hide