Symlink to File Outside Root Directory

I have a git repository that has the page I want to deploy (a mkdocs site) in a subfolder.
In that repository, I have a top level file.
I want to include this file in my site. Since mkdocs doesn’t allow relative links outside the documentation directory, I’m using a symlink to the changelog file:

++ mkdocs/
 +- mkdocs.yml
 ++ docs/
  +- [link] (../../

To deploy, I’m using mkdocs/ as the root directory. When I deploy the site on Cloudflare, the deployment fails, because it can’t find the file (Error reading page '': [Errno 2] No such file or directory: '/opt/buildhome/repo/docs/').

I made a reproduction repository on GitHub at Nerixyz/cf-pages-symlink-repro. There, I included two symlinks in the documentation: and mkdocs/ I deployed the repository with the root directory set to mkdocs.

This is the expected behavior when changing the root directory. Cloudflare with “forget” about any files that exist outside of the selected directory. You should have the root directory be set to the root level and have the build command be something like cd mkdocs && mkdocs build with the output directory set to /mkdoc/docs (unless your output directory is different).


Thanks for the answer!

cd mkdocs && mkdocs build doesn’t quite work. I needed to use cd mkdocs && pip install -r requirements.txt && mkdocs build (since mkdocs isn’t installed by default).

Some minor thing: In my actual project, I have a package.json in the root directory and the runner tries to install its dependencies, which I don’t need.

If you are on build image v2 then you can set an environment variable of SKIP_DEPENDENCY_INSTALL to any value to skip that part.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.