Set trailingSlash: true for @site.url

Ghost policy is to add a trailing slash to all URLs generated.
However, it was not doing that for @site.url. That created a problem
for Ghost installations at subdirectories, because requests to the
generated URL like example.com/blog would be redirected by Ghost to
the trailing-slash version like example.com/blog/. That redirect
harmed SEO.

This replaces trailingSlash: false with trailingSlash: true in the
@site.url generation. Now Ghost complies with it's trailing slash
policy and avoids creating an unnecessary, SEO-harming redirect.
This commit is contained in:
Dan Jensen 2023-08-29 09:45:00 -05:00
parent 492c26c6ac
commit c022d8ec5b

View File

@ -9,7 +9,7 @@ function updateLocalTemplateOptions(req, res, next) {
// adjust @site.url for http/https based on the incoming request
const siteData = {
url: urlUtils.urlFor('home', {trailingSlash: false}, true)
url: urlUtils.urlFor('home', {trailingSlash: true}, true)
};
// @TODO: it would be nicer if this was proper middleware somehow...