Reputation: 4887
I've built an internal documentation site using Material for MkDocs but I would like to provide multiple project readmes by symlinking folders from their own git repos into the docs/
folder. That is, given two projects:
/home/user/projects/first_project.git
which has documentation in Guide/
/projects/second_project.git
which has its documentation also in Guide/
I can copy /home/user/projects/first_project/Guide
into the docs/
directory and it serves the necessary documentation.
But since I don't want to potentially forget to rsync
folders, I thought I should symlink them:
ln -s /home/user/projects/first_project/Guide docs/first_project_guide
ln -s /projects/second_project/Guide docs/second_project_guide
This lets me access the separate guide folders in the command line, but mkdocs doesn't seem to know how to build through symlinks. Does anyone know how I can configure mkdocs to do so?
This is the error I see:
INFO - [01:57:11] Detected file changes
INFO - Building documentation...
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/mkdocs/livereload/__init__.py", line 193, in _build_loop
func()
File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 67, in builder
build(config, live_server=None if is_clean else server, dirty=is_dirty)
File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/build.py", line 337, in build
files.copy_static_files(dirty=dirty, inclusion=inclusion)
File "/usr/local/lib/python3.11/site-packages/mkdocs/structure/files.py", line 111, in copy_static_files
file.copy_file(dirty)
File "/usr/local/lib/python3.11/site-packages/mkdocs/structure/files.py", line 290, in copy_file
utils.copy_file(self.abs_src_path, self.abs_dest_path)
File "/usr/local/lib/python3.11/site-packages/mkdocs/utils/__init__.py", line 132, in copy_file
shutil.copyfile(source_path, output_path)
File "/usr/local/lib/python3.11/shutil.py", line 256, in copyfile
with open(src, 'rb') as fsrc:
^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/docs/first_project_guide'
Note: This is a duplicate of https://superuser.com/q/1827866/231154 because I first thought it would be more appropriate to ask there, but I don't have enough reputation to create tags there which already exist here.
Upvotes: 1
Views: 334
Reputation: 6204
I was having the same issue. Then I switched to hardlinks and it works.
Just to ln <source> <destination>
instead of ln-s
Upvotes: 1