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 to allow for local testing. #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

seanfisk
Copy link
Contributor

Newer versions of Jekyll introduced the site.baseurl configuration option, which is useful for testing the site locally. This commit adds support for site.baseurl to this theme.

site.url is now used for the protocol and domain name only, without a trailing slash. site.baseurl, if specified, has a leading slash and no trailing slash.

In many instances, site.url has been replaced by site.baseurl where the protocol and domain are not necessary (e.g., <a>, <img>, etc.). site.url is now used in the following places:

  • the canonical link
  • the feed link and within the feed
  • sharing, including Open Graph
  • search

Some advice for where to use each comes from this StackOverflow post, and other changes were based on the scaffolding generated by the latest version of Jekyll (3.0.3).

I've done quite a bit of testing (via jekyll serve and GitHub Pages), but it's certainly possible I missed something. Thanks for maintaining this theme! :)

Newer versions of Jekyll introduced the site.baseurl configuration
option [1], which is useful for testing the site locally. This commit adds
support for site.baseurl to this theme.

site.url is now used for the protocol and domain name only, without a
trailing slash. site.baseurl, if specified, has a leading slash and no
trailing slash.

In many instances, site.url has been replaced by site.baseurl where the
protocol and domain are not necessary (e.g., <a>, <img>, etc.). site.url
is now used in the following places:

- the canonical link
- the feed link and within the feed
- sharing, including Open Graph
- search

Some advice for where to use each comes from this StackOverflow post
[2], and other changes were based on the scaffolding generated by the
latest version of Jekyll (3.0.3).

[1]: https://jekyllrb.com/docs/upgrading/0-to-2/#baseurl
[2]: http://stackoverflow.com/a/27400343
@jrfnl
Copy link
Contributor

jrfnl commented Mar 15, 2016

Relative urls are considered bad practice by most, so if the site.baseurl would be used, then it should always be combined with site.url.
Also see: https://yoast.com/dev-blog/relative-urls-issues/

Just my two pennies, feel free to disregard.

@seanfisk
Copy link
Contributor Author

@jrfnl To be clear, this pull request is less about pushing root-relative URLs into this theme than bringing the theme up to speed with what Jekyll currently does. Jekyll's addition of site.baseurl basically splits the old site.url into two parts:

  • The part that is always included in the URL (i.e., site.baseurl)
  • The part that is used to make the URL absolute (i.e., the new site.url)

The names are admittedly not as clear as they could be, though that was Jekyll's choice, not mine.

Jekyll uses root-relative URLs in its generated scaffolding by default, with the exception of the canonical URL and the feed. However, I understand that others may want to use absolute URLs everywhere. Fortunately, if this pull request is accepted, that is still rather simple:

url: ''
baseurl: http://aronbordin.com/neo-hpstr-jekyll-theme

This works because whenever site.url is used, site.baseurl is added to the end. There are no instances (at least in this theme) where site.url is used without site.baseurl. I've tested this configuration and confirmed it works as expected.

I've added a block to _config.yml explaining the configuration one would use for absolute URLs. Let me know if that works for you! Thanks for the input :)

@ccjjmartin
Copy link

Tested this patch and found the following:

  1. This did not cleanly apply on my local environment because of the url settings in _config.yml but github says it merges cleanly with no problems ... so this is probably fine.

  2. Using this patch the Favorites link appears to be broken (sending to 404). It should have a leading forward slash on line 29:

  - title: 'Favorites'
    url: '/#'
  1. Drop downs from Categories appear to be broken in local environments.

Everything else appears fine when testing locally. I really like the idea of using the new baseurl configuration setting. Hope when this gets fixed it gets merged.

@aron-bordin
Copy link
Owner

Hi @seanfisk thanks for your contribution and sorry for this loooooooong delay.

I've made some big modifications in master, can you allow me to edit your commits ? I'd like to update this pr to the new project structure :)

Thank you

@seanfisk
Copy link
Contributor Author

seanfisk commented Dec 3, 2016

No worries, @aron-bordin! Believe me, I understand being busy 😉

Feel free to edit my commits as you desire! I can try to fix issues including some of those mentioned by @ccjjmartin if I have time as well.

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

Successfully merging this pull request may close these issues.

4 participants