Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use {{ site.baseurl }} instead of {{ site.url }} #216

Closed
wants to merge 1 commit into from
Closed

use {{ site.baseurl }} instead of {{ site.url }} #216

wants to merge 1 commit into from

Conversation

doka
Copy link
Contributor

@doka doka commented Sep 11, 2016

Theme runs nicely on Github Pages if the site is setup as users or organizations pages, but links are broken if the site is a project page, see #215.

This PR is to correct this behavior by replacing {{ site.url }} by {{ site.baseurl }}.

See more info here.

@mmistakes
Copy link
Owner

This is an improper use of baseurl, see https://byparker.com/blog/2014/clearing-up-confusion-around-baseurl/

If you're going to use it both should be define eg. {{ site.url }}{{ site.baseurl }}

A better way to support url and baseurl is to do it similar to how I've done it in my other theme.

{% if site.url %}
  {% assign base_path = site.url | append: site.baseurl %}
{% else %}
  {% assign base_path = site.github.url %}
{% endif %}

Which is in an include and can be used as the variable {{ base_path }}.
Eg. <a href="{{ base_path }}{{ post.url }}">{{ post.title }}</a>

@sanmai
Copy link

sanmai commented Sep 13, 2017

What about relative_url and absolute_url?

{{ "/docs/assets/" | absolute_url }} => https://jekyllrb.com/myproject/docs/assets
{{ "/docs/assets/" | relative_url }} => /myproject/docs/assets

More info.

@mmistakes mmistakes mentioned this pull request Jan 19, 2018
48 tasks
@mmistakes
Copy link
Owner

baseurl and url have been correctly used in the theme by relying on Jekyll's relative_url and absolute_url filters as @sanmai pointed out.

Currently in #265, and will land when merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants