Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow symbolic link directories #503

Closed
getreu opened this issue Oct 29, 2018 · 11 comments
Closed

Follow symbolic link directories #503

getreu opened this issue Oct 29, 2018 · 11 comments

Comments

@getreu
Copy link
Contributor

getreu commented Oct 29, 2018

Gutenberg follows symbolic links to files already, but not yet symbolic links to directories.
This feature would be very handy, because then you could just link assets under /static wherever they live. The same reasoning applies to /content and the other directories,

@Keats
Copy link
Collaborator

Keats commented Oct 30, 2018

I can see the point for the static folder but I'm not sure I see it for content. When would you have gutenberg md files used outside of the content folder?

@getreu
Copy link
Contributor Author

getreu commented Oct 30, 2018

A useful consistent policy could be:

  1. All absolute and relative symbolic links (dirs and files) referencing assets outside the Gutenberg tree are followed: The referenced assets are copied into /public/.
  2. All relative symbolic links (dirs and files in /content or /static) referencing assets inside /content or /static not followed. The relative symbolic links are copied as they are into /public. They will be followed later by the Web-server, when the web page is accessed.

Advantages and use case:

  1. This feature would be very handy, because then you could just link assets under /static wherever they actually live. The same reasoning applies to /content and the other directories. Use case: documentation and blog content is kept in each project folder and are linked into the Gutenberg tree with symbolic folders. No need to copy assets from outside into /content and /static before launching gutenberg.
  2. Internal symbolic links are useful to avoid redundancy when you have identical content on different pages.

The most important is to implement 1) the "follow links behaviour" for symbolic directory links (for files it works already).

No 2) is a nice to have

@getreu
Copy link
Contributor Author

getreu commented Oct 31, 2018

BTW: I am using a script to assemble assets to be published dynamically using symbolic directory links. If you are interested how it works see 1.3 in A collection of Bash scripts - bash-scripts.pdf.

@Keats
Copy link
Collaborator

Keats commented Nov 9, 2018

@getreu are you willing to work on a PR to add that?

@getreu
Copy link
Contributor Author

getreu commented Nov 12, 2018

@Keats : I would like to and had a look into your code by curiousity (knowing that I do not have any free resources until the end of the year). I like the way you modulerized your code base.
Concerning the work load for a PR on this:
(Policy 1): you follow symbolic file links already, following symbolic directory links should be straightforward: 2-3 lines of code
(Policy 2): To decide if a symbolic link points inside the "path" tree and - if it does - create the same relative symbolic link in ./public/ is not very complicated either (special case here is Windows OS): 2-3 lines of code.
More work is to enhance test-site and to add some appropriate tests.

Nevertheless, my workload does not allow me to accept any additional project now. Sorry.

@2mol
Copy link
Contributor

2mol commented Dec 16, 2019

I can see the point for the static folder but I'm not sure I see it for content. When would you have gutenberg md files used outside of the content folder?

I just came across this because I wanted to know if zola serve could watch files for changes that are symlinked. The site builds fine, but changes in the symlinked file don't trigger a rebuild.

To answer your question: I like to manage my writing in a central location, and it becomes messy when I duplicate blog posts etc. So I'd love to be able to just symlink individual .md files into content/.

@bemyak
Copy link
Contributor

bemyak commented Sep 26, 2020

Both initial building and watching for changes already work on master brunch, so the issue can be closed I suppose.

@Keats Keats closed this as completed Sep 26, 2020
@getreu
Copy link
Contributor Author

getreu commented Oct 8, 2020

follow up here in zola.discourse
As a follow up of hard_link_static = true which is a huge improvement for my setup. Thank you.
It allows me to publish a whole site without copying any content:

  • Assemble the static content with symbolic links to selected directories in you project.
  • Reconstruct the tree with hard links to files as leaves in static.

For the latter I use the attached script.
Here my suggestion: include the scripts functionality in Zola.

#!/bin/sh
# FROM_DIR must be in the same directory where `config.toml` is.
FROM_DIR="blog3/static-symlinks"

cd "$FROM_DIR"
# create directories
find -L -type d -not -name . -exec mkdir -p "../static/{}" \;
# populate them with hard links
find -L -type f -not -name . -exec ln -L "{}" "../static/{}" \;

@bemyak bemyak mentioned this issue May 29, 2022
2 tasks
@pinpox
Copy link

pinpox commented Jul 22, 2022

Does zola serve still work with symbolic links as static assets? I get 404 when trying to load assets that are a symlink inside the ./static directory

@bemyak
Copy link
Contributor

bemyak commented Jul 25, 2022

@pinpox, it was broken in 0.15 but should be fixed in 0.16. Can you check it, please?

@pinpox
Copy link

pinpox commented Jul 25, 2022

@pinpox, it was broken in 0.15 but should be fixed in 0.16. Can you check it, please?

My bad, didn't notice I'm running zola 0.15.3. I'll update the package for my distribution then and report back!
EDIT: Update is submitted here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants