Jekyll Posts Not found

2019-09-06 15:36发布

问题:

So I setup a Jekyll page, I created a few demo posts, got a navigation between them working and styled it to my liking and then went 'jekyll' in the root.

This generated a _site folder in my root. Awesome.

But when I open this folder in browser, and try to navigate between posts, it attempts to go to file:///2013/02/01/post-title.html instead of the actual location, which would be file:///blablabla/_site/2013/02/01/post-title.html

I've been looking at Permalinks options in the yml-file, but I havent found a working solution yet.

I use:

<a href="{{page.previous.url}}" title="Previous Post: {{page.previous.title}}">
{{page.previous.title}}</a>

To navigate between posts, and:

{% for post in site.posts limit: 5 %}
    <a href="{{ post.url }}">{{ post.title }}</a>
{% endfor %}

to link the posts from the main page.

From my config.yml:

baseurl:     /
url:         http://localhost:5000
source:      .
destination: ./_site
permalink:   /writing/

Taking any hints here! Thanks

回答1:

So what I did was:

In my _config.yml, I added this:

baseurl:     /
url:         http://some.link.he.re/~nameofdir/big_blog

And for assets like CSS/JS I simply used {{ site.url }} to pre-fix all my actual assets.:

<link href="{{ site.url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />

For navigation I did:

<a href="**{{site.url}}**{{page.previous.url}}" title="Previous Post: 
{{page.previous.title}}"> {{page.previous.title}}</a> 

In my post.html layout, I added: in the , I am not sure if this is necessary though, but for now it will linger.

For all static pages I added:

<li><a href="**{{site.url}}**/journal.html">Journal</a></li>

And finally, even though it's the same thing all over, for linking posts:

<a href="{{site.url}}{{post.url}}">{{ post.title }}</a>

So {{ site.url }} is the same as what you write in _config.yml at url: xxxx, And if you're hosting your page on a server that has odd directory structure (like my university for example), you need to give url: the value of the actual root catalog, that means include the blog-folder-name as the last folder in the url. Then just prefix all your links, static or jekyll-generated by {{ site.url }} and you should be cool!