I've recently upgraded to jekyll 1.0 and as a result post links now have a leading '/'.
Setting relative permalinks to true or false doesn't seem to change the generation of {{post.url}} at all, they always seem to come out with a leading slash.
I understand that I could use base_url, but I pass on the completed project to an organisation that ends up hosting it wherever (I don't know the URLs).
My config file that used to work was simply:
permalink: articles/:title
Any help would be great!
A relative URL provides only the tag of an absolute URL. If you want to link to a product page from a category page, you would use the following HTML relative URL: <a href=”product”>. It is assumed that if a relative link appears on a certain page, that exact page should be used as its root.
When you run jekyll serve locally, it starts a web server, usually at http://localhost:4000 , that you use to preview your site during development.
Jekyll is a static site generator. It takes text written in your favorite markup language and uses layouts to create a static website. You can tweak the site's look and feel, URLs, the data displayed on the page, and more.
I'm seeing the same thing in Jekyll 1.0.3 install. Seems like a bug. Either way, a work around is to use a Liquid Filter to remove the first slash.
{{ post.url | remove_first:'/'}}
With the following pagination layout:
{% for post in paginator.posts %}
<div class="postWrapper">
<h2><a href="{{ post.url | remove_first:'/'}}">{{ post.title }}</a></h2>
<div class="postDate">{{ post.date | date:"%B %d, %Y" }}</div>
<div class="postContent">{{ post.content }}</div>
</div>
{% endfor %}
And your same _config.yml
setting:
permalink: article/:title
Links are generated without the leading slash (e.g. <a href="article/the-title">The Title</a>
).
Just be aware that if it is a bug and it gets fixed, you'll have to adjust your code to drop the 'remove_first' filter. Otherwise, it'll strip the slash in the middle of your link and break it that way.
We noticed the same thing, and I tracked it down to the addition of baseUrl being exposed to liquid templates. In 0.12.1 baseUrl was not configurable in _config.yml and was defaulted to ''.
In 1.0.0 you could set it in the config and it defaults to '/' which is why you're seeing this. I don't believe it is a bug as it is still present in current (1.4.3) versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With