[solved] Static files (documents, ...) and subdirectory publishing

hello,
I have created a static directory like https://www.getzola.org/documentation/getting-started/directory-structure/ suggest. I have put some files, and using zola serve, it works perfectly but, when I use gitlab page to publish it, I have a path issue.

if my files is static/files/foo.odt, if i have content/bar.md

+++
title = "Some page"
+++

click [here](/files/foo.odt) to download

with zola serve, it will be translated to

click <a href="/files/foo.odt">here</a> to download

that’s totally correct

but, because github page will publish inside a subdirectory the link should be

click <a href="/sub-directory/files/foo.odt">here</a> to download

So is there some helper to use to have a proper link?

2 Likes

well, I solve myslef

I have created a shortcode (/shortcodes/static_link.html)

<a href="{{ get_url(path = file) }}" target="_blank">
    {{ label }}
</a>

and then use it

+++
title = "Some page"
+++

click {{ static_link(label="here", file="/files/foo.odt") }} to download

and voilà!

2 Likes