Andry
Andry

Reputation: 16875

Wrong links to posts in GitHub pages with Jekyll

I have started using GutHub-Pages. I am using Jekyll and my gh-pages repository has the following structure:

gh-pages (repo)
+-site
| +-_posts
|   +-2016-02-15-post1.md
| +-_config.yml
| +-index.html
+-notes.md

My index.html is like this:

---
layout: default
---

<div class="home">
  <h1 class="page-heading">Posts</h1>
  <ul class="post-list">
    {% for post in site.posts %}
      <li>
        <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
        <h2><a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a></h2>
      </li>
    {% endfor %}
  </ul>
  <p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | prepend: site.baseurl }}">via RSS</a></p>
</div>

Wrong paths

So I can get to my pages url: http://<username>.github.io/<project-name> and land in index.html just fine. But when i click on a link post, I get this address:

http://<username>.github.io/jekyll/update/2016/02/15/post1.html

Which leads to a 404 as the correct path is:

http://<username>.github.io/jekyll/<project-name>/update/2016/02/15/post1.html

The project name folder is not counted!

Upvotes: 2

Views: 669

Answers (1)

David Jacquel
David Jacquel

Reputation: 52829

In _config.yml, set

baseurl: /project-name

Upvotes: 2

Related Questions