I am currently working on a 11ty project and really like it. But I have a problem with the links when I deploy the output. I'd like to deploy it to 2 different locations on separate servers. One of the locations is in the root directory, the other one in a sub-folder.
Is it possible to have relative links in the output?
I already tried pathPrefix, but either I don't use it properly or it just doesn't give me the result I am looking for.
.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',
}
}
}
When I run eleventy --config=eleventy.config.js --serve
, an additional folder gets generated with the name _eleventy_redirect
, including an index.html
file with:
<!doctype html>
<meta http-equiv="refresh" content="0; url=/subfolder/">
<title>Browsersync pathPrefix Redirect</title>
<a href="/subfolder/">Go to /subfolder/</a>
When I run eleventy --config=eleventy.config.js
(without the --serve
), that folder isn't there.
However, either way all the links are absolute (e.g. Home is href="/"
), and the site doesn't work on the server.
Is there a way to have either relative links (e.g. Home is href="./"
on the root index.html and href="../"
on sub pages) or at least include the subfolder in the urls (e.g. Home is href="./subfolder/"
)?