I am currently engaged in a project using Eleventy (11ty) and I must say, I am quite impressed with it. However, I have encountered an issue regarding the links when deploying the output. My intention is to deploy it to two different locations on separate servers - one at the root directory and the other within a sub-folder.
My main concern is whether it is possible to utilize relative links in the output?
I have already experimented with the pathPrefix feature, but either I am not implementing it correctly or it is not yielding the desired outcome that I seek.
.eleventy.js:
module.exports = eleventyConfig => {
...
// Include our static assets
eleventyConfig.addPassthroughCopy("images")
return {
pathPrefix: "/subfolder/",
templateFormats: ["md", "njk"],
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
passthroughFileCopy: true,
dir: {
input: 'site',
output: 'dist',
includes: 'includes',
data: 'globals',
}
}
}
Upon running
eleventy --config=eleventy.config.js --serve
, an additional folder named _eleventy_redirect
is generated with an index.html
file containing:
<!doctype html>
<meta http-equiv="refresh" content="0; url=/subfolder/">
<title>Browsersync pathPrefix Redirect</title>
<a href="/subfolder/">Go to /subfolder/</a>
Running
eleventy --config=eleventy.config.js
without the --serve
does not create this folder. Nonetheless, all the links remain absolute (i.e., Home is href="/"
), hindering the functionality of the site on the server.
Is there a way to implement relative links (e.g., Home as href="./"
on the root index.html and href="../"
on sub pages) or at least incorporate the subfolder into the urls (e.g., Home as href="./subfolder/"
)?