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