mtleis
mtleis

Reputation: 732

url of navigations of jekyll posts do not work when pushed to github

I wanted to add the navigation capability to my blog posts on github pages.

I added the following code into my post.html:

<div class="PageNavigation">
  {% if page.previous.url %}
    <a class="prev" href="{{page.previous.url}}">&laquo;
        {{page.previous.title}}</a>
  {% endif %}
  ...
</div>

When I push the posts to github, the link will not work due to the fact that code is residing under a repository url. As a workaround, I added the repo name manually to the link. It becomes:

 <a class="prev" href="/myRepoName{{page.previous.url}}">&laquo;
        {{page.previous.title}}</a>

Now the problem is that the navigation is not working locally. Is there a simple solution to avoid this mess?

Upvotes: 1

Views: 309

Answers (1)

David Jacquel
David Jacquel

Reputation: 52829

In _config.yml :

baseurl: /myRepoName

Link looks like :

<a href="{{ site.baseurl }}{{ page.previous.url }}" class="prev">
  {{page.previous.title}}
</a>

Upvotes: 3

Related Questions