Relative path for my website

Hello,

I have developed with Zola a website that works well on my local computer, however I do have a problem for Deploying it on the server of my website.

The problem is that the address of my website will be of this form :
http://some/adress.com/mywebsite
and that all the addresses I am allowed to access are of the form
http://some/adress.com/mywebsite/example
and not
http://some/adress.com/example

So I can fix it by modifying manually all the links in my markdown pages like this :
[a link](/Some/link.pdf) becomes [a link](/mywebsite/Some/link.pdf)

The problem with doing so, is that I will no longer be able to test my website in local because it won’t work in local afterward.

Is there any solution to get a zola project able to serve both in local and on the server in my case ?

I would be great if someone could show me a way !

Thanks.

Hi, i’ve had this issue as well but i didn’t find a workaround yet. There is a discussion about inconsistencies in paths/links here

What is the base_url in your config? It should include mywebsite

Yes it’s include.
I finally changed all the links, so the website is working now perfectly on the server, but when I locally serve it with zola serve, I need to remove manually in the url all the /mywebsite to navigate for most of the links (except the ones between markdown pages with your notation @/some/link.md for which I didn’t need to modify).

I (naively) tried zola serve --base-url 127.0.0.1/mywebsite/ and zola serve --interface 127.0.0.1/mywebsite/ to make it still work in local, but without success.
By the way I didn’t get the difference between interface and base-url (I am a very newcomer to web programming)

In my case, the problem is accessing content from the webroot when the base_url is a subfolder.

A markdown absolute link produces (as expected) an HTML absolute link, as expected. A relative link will produce a relative link.

I guess what i would like to do is something like [link](@/foo) where foo could be in static, or could be some file inserted outside of zola in my build pipeline. Have i missed something or is it not possible yet?

interface is the network interfaced on which you receive connections (wifi/ethernet/localhost), you should not have to change that in most cases. --base-url was indeed the option you were looking for.

zola serve --base-url "http://127.0.0.1/mywebsite"

1 Like

Thanks for the help, however, when I am doing as you say
zola serve --base-url "http://127.0.0.1/mywebsite"it still says that
the web server is available at http://127.0.0.1:1024, and the only thing that changes is that I have no more css style display when navigating through the website…

Yeah it seems serve command was not built to be used with subfolders, although the output you just mentioned is an output bug, URLs should be generated properly (but placed in public/ not public/website/ so it won’t work to simulate your use).

As a trick to test the subfolder locally, you can build your site with the correct URL with zola build, then create a symbolic link from mywebsite to public/, and serve the whole website folder (who will therefore have a /mywebsite/) subfolder:

$ zola build --base-url "http://127.0.0.1/website"
$ ln -s public/ staticadventures
$ python -m SimpleHTTPServer 8000

This should simulate your usecase locally. Let me know if that’s not the case or if you have any trouble.

1 Like

Thx for the trick.

But it doesn’t work for me, with your trick its now serving like this:

  • the links that used not to work with zola serve (the ones like [link](/some_link) ) are now working
  • but the links that were still working with zola serve (the ones like [link](@/some_link) ) now don’t work !
  • and it doesn’t load css sheet

Ok I finally manage to serve it locally now with

$ zola build --base-url "http://127.0.0.1:8000/mywebsite"
$ ln -s public/ mywebsite
$ python -m SimpleHTTPServer 8000

It was the :8000 that was missing in the zola build --base-url "http://127.0.0.1/website"

Thanks for all !

It would be effectively great if in the future a command like this could work directly :

zola serve --base-url "http://127.0.0.1/mywebsite"
1 Like

My bad sorry :slight_smile: Glad you got it working.