Search code examples
jekyllmod-proxy

Jekyll: need all hrefs to be relative or start from server.domain


I have a jekyll local website that hopefully will be made public. The only way for me to do so is to use mod_proxy on apache2. Unfortunately only the main page works correctly. Others are not forwarded, because the links Jekyll creates look like:

<a href=/mysite/2015/07/17/About/>About</a></li>

I need them to be either relative, i.e. or to be really absolute, i.e.:

<a href=http://my.server.com/mysite/2015/07/17/About/>About</a></li> 

Only in that case mod_proxy will be able to substitute http://my.server.com/mysite with localhost:4000/mysite

Now, links done by Jekyll that start with / are dispached as they would be served by the main website i.e. the one hosted on http://my.server.com/


Solution

  • In your _config.yml file, you can set your base url like the following:

    url: http://www.example.com
    

    You can call this variable later using liquid markup:

    <a href="{{ site.url }}/path-to-your-stuff"></a>
    

    And you have an absolute URL.