getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
13.44k stars 941 forks source link

Support wiki-style internal page links #2104

Open heitorPB opened 1 year ago

heitorPB commented 1 year ago

It would be great for Zola to support wiki-style page links (a.k.a. wikilinks).

Wiki-links are in the format [[Foo Bar]] that translates to [Foo Bar](path/foo-bar) and [[Foo Bar|Custom Title]] that translates to [Custom Title](path/foo-bar). Those links are for internal pages only.

This format is used in:

I know Zola has its own format for that (which is much more comfortable to use than what I saw on other systems), but Wiki links are gaining a lot of popularity. Supporting that would make the transition from other systems to Zola easier (my particular use case) and would add good tooling support to editing Zola-powered websites (in Vim/Neovim, hitting on a markdown/wiki link opens that document).

This was requested on the Forums but it was dismissed without discussion. There was another forum post that mentions the lack of support for wikilinks.

c-git commented 1 year ago

The maintainer did respond and say it wouldn't be supported on the first request that you mentioned. But if I may add my 2 cents. There are already 2 ways to add links in Common Mark which is what Zola uses. I am all for options but too many options can lead to confusion, make the project more difficult to maintain and actually lead to a "less good" product in the end.

I'm of the opinion that you can add a "preprocessor" before you call zola that would convert the "wiki links" to one of the options supported in common mark. I'm happy to give a try at helping with the preprocessor if that is an option you think would meet your needs.

A general sketch of what I'm thinking is you have this program that will run through the content folder and look for a regex that matches the format and the use a capture group to get the info and the replace it in place by editing the file. (Maybe backing it up first?)

Keats commented 1 year ago

Yeah as mentioned by @c-git we already added a way to add link that is not in CommonMark. Adding another way to do the same thing but less powerful/obvious is not going to happen.

How would you link to the following files with Wiki links for example:

heitorPB commented 1 year ago

I agree with you to avoid feature creep. That can easily add a huge burden on the dev team. Adding features that are not exactly new should be decided with care. That's why I started this issue: to have this discussion :)

I'm of the opinion that you can add a "preprocessor" before you call zola that would convert the "wiki links" to one of the options supported in common mark

I'm currently using this strategy. I have a Perl script that "translates" wiki links. But as my internal wiki grew, this script is now taking ~10s to parse all my ~2k pages. This is getting too annoying for me.

As for pages with same title, but in different places, I have something like this in my Ultimate Index page:

In the wikilink format you can specify a path to the file to solve any ambiguity.

c-git commented 1 year ago

I'd add a small db to check last modified time to avoid processing files that have already been processed and that should cut down the runtime substantially.