Easy markdown to website

I wanted to be able to generate a website from my markdown files using zola without having to modify the markdown files ( no adding @/ on the links nor changing file locations, etc) . This way I could reuse markdown editors such as obsidian to manage links and assets.

To do this I had to find a solution to issue #877 making links to relative assets work, without your file having to be named index.md, linking to internal content in non-markdown content and that links to .md files do not get translated into links to .md files unless you add @/ in front.

So I added 2 features to my local build:

ugly-urls: if set ugly_url = true on config.toml, file.md gets mapped to file.html. However index.md still behaves as is: a link to foo/index.md becomes a link to foo/ so that people can force the pretty urls by explicit using index.md. This fixes the issue #877 as now the relative link of files is valid. It also makes link work from non markdown content, as the structure is preserved.
It makes all assets in the same parent folder be page assets, even if the page is not called index.md. This doesn’t cause any new issues or causes files to collide, because it just preserves the current structure. However this can be problematic when there are permalinks to different folders.(28 lines in 4 files)

md_local_link: if set md_local_link on config.toml , any non external link that ends in .md is parsed as a local link. This way [file](file.md) becomes a link to (Path generated by file.md) , and gets properly checked. The behavior is the same as [file](@/file.md), except that it also handles relative links, even with ugly-url turned off. (16 lines in 2 files, could likely be shorter though)).

And I changed the behavior of specifying page paths on the page meta: if you specify path = file.html, it will generate file.html rather than file.html/index.html, and if you specify path = file/, with a final slash, it generates file/index.html even if using ugly-url, so you can override the default behavior for specific pages independent of the url mode.

I’d like to submit a pull request if any of these features could be useful. If they could be, should I split those features into separate PRs? Some posts requesting this are: Making clickable links and viewable images in editor, #686, #877 ,#2271 and #840

I don’t think we want either in Zola:

  1. ugly-urls: I don’t like the concept and it’s probably never going to get in Zola. There’s no reason if you want ugly_urls to only have them sometimes, eg if you have colocated assets. Then you have different behaviours for trailing slashes, eg /foo will be /foo.html and /foo/ will be /foo/index.html (if the webserver even supports such redirects). To solve #877 correctly , you would need to copy the assets for every .md files in the directory otherwise you can have broken links. This is obviously opinionated but is something that could live in a fork if people really want it, not in the project itself.

  2. Adding the @/ prefix is intentional, we don’t want to conflate zola internal links with relative links since we cannot validate links (some people are adding files from other sources after the zola build and we don’t want to error because of that.

if I’m allowed by work, I’ll maintain a fork with those features. It might take a couple weeks for me to get authorization though. I’ll update here when this happens.

Here is a link to the patch: Comparing getzola:master...itf:easy-markdown · getzola/zola · GitHub