Reputation: 350
I am build my jekyll page and i just uploaded to gh-pages. When i click on my post links i get a 404 error here is my setup.
_config.yml
baseurl: ""
url: "bousis.github.io/blog"
permalink: /blog/:title
here is the code in the index
<ul class="posts">
{% for post in site.posts %}
<li>
<a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
<span class="right date">{{ post.date | date_to_string }}</span>
</li>
{% endfor %}
</ul>
i have my baseurl: ""
because this is the only way could get my css to load. removing the leading /
from the head.
<link rel="stylesheet" href="{{ "css/main.css" | prepend: site.baseurl }}">
here is my folder tree [folder tree]1
what i want to achive is be able to have something like this in my url
bousis.github.io/blog/welcome-to-jekyll to link to my post
or it would be perfect if i could get
bousis.github.io/
as index
and bousis.github.io/welcome-to-jekyll
for my posts
Thanks,
Upvotes: 0
Views: 2160
Reputation: 52829
Create a bousis.github.io
repository and push you jekyll sources in the master
branch.
You're _config.yml is then :
baseurl: ""
url: "bousis.github.io"
permalink: /:title
Upvotes: 3
Reputation: 6967
In addition to David Jacquel's correct answer, should you want to achieve the previous bousis.github.io/blog/welcome-to-jekyll
style links, you are almost correct, you would just need to set the baseurl
to blog
, instead of the entire address. While your url
will have the value of bousis.github.io
.
So you would have these values:
baseurl: blog/
url: "bousis.github.io"
permalink: /:title #this actually works now, it didn't for me last time, not sure why
After which you need to follow the tutorial at GitHub Pages for a project site, where you create a repository named blog
with a gh-pages
branch. (Or if you already have a repository, just create a gh-pages branch), GitHub will give you a url in the format of username.github.io/name-of-repo
And then finally go ahead and push your Jekyll site to that branch in that repo.
Note: pretty
permalinks will display posts with the date as well, if you prefer that.
A good reference on using baseurl can be found on this blog post titled : Clearing up Confusion around Baseurl - Again. And this write up on how to handle permalinks in Jekyll.
It is recommended to set your own permalinks for non-post pages, such as if you have an about
page, make sure to explicitly set the permalink as /about
to avoid any possible collision if you have a post
named about
. This shouldn't happen if you keep note of it, but might save you headaches in the future if you somehow create a post titled about
.
Upvotes: 3