question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

site.url versus site.baseurl

See original GitHub issue

What is the intended difference between site.url and site.baseurl? The example in _config.yml is:

# This URL is the main address for absolute links. Don't include a slash at the end.
#
url: 'https://phlow.github.io/feeling-responsive'
baseurl: ''

But in the footer, site.baseurl is the prefix for items without “http” in the URL, which results in that link being broken (I’m seeing links to “http://phlow.github.io/feed.xml” on your demo, a 404). There are also many instances of site.url and site.baseurl being put together, like this:

{{ site.url }}{{ site.baseurl }}/assets/img/{{ site.logo }}

My best guess is that site.url is supposed to be the domain name, and site.baseurl is supposed to be the root directory of the site (if any). So the example page should actually be:

url: 'https://phlow.github.io'
baseurl: '/feeling-responsive'

This way, an absolute link is {{ site.url }}{{ site.baseurl }}, and a relative link is just {{ site.baseurl }}.

After I set my config file like this, and then went through all the code I could find using these variables and adjusted them accordingly, I stopped getting broken links. I’m not too familiar with Jekyll, though, so I’m not sure if this structure is correct, or unusual, or breaks a standard convention.

Edit: That is to say, I made this change and then different stuff was broken 😃 But I was able to fix the new broken links, etc. and get my site working properly as far as I can tell.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jbiatekcommented, Aug 20, 2015

Ah, where was that article when I was trying to learn more about site.baseurl? Thanks very much for that.

I suppose either method works (putting the entire URL in site.url and leaving site.baseurl blank, versus splitting it between the two). After all, when they get concatenated together it’s the same result in the end.

But the benefit of splitting them up is that when testing the site with jekyll serve, having a baseurl will create a more realistic testing environment. Otherwise, if you write a link like /whatever.html and it never gets prefixed, it’ll work while testing but break in production. With a baseurl, anything that’s not found in localhost:4000/baseurl/ will be broken, as it should be. As I pointed out before, in the demo for the theme, the links to the RSS and Atom feeds are only broken in production, not when run locally, and it’s because when testing, everything ends up in the root directory.

0reactions
Phlowcommented, Aug 20, 2015

I recommend this article by @parkr Clearing Up Confusion Around baseurl

I generally prefer to use only direct absolute links, that’s why I use it in all links in the theme {{ site.url }}. I think the {{ site.baseurl }} is just confusing. Use absolute links with the help of {{ site.url }} and everything works on every page. But some people like to use and use {{ site.baseurl }} like this pull request asked for:

But you can combine them with {{ site.baseurl }}. Just check out the article.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jekyll's site.url and baseurl - Made Mistakes
url, A site's full URL including protocol, domain, and port (if applicable). ; baseurl, Name of sub-directory the site is served from e.g.,...
Read more >
what is the difference between site_url() and base_url()?
if you want a URL access to a resource (such as css, js, image), use base_url() , otherwise, site_url() is better. for a...
Read more >
Clearing Up Confusion Around baseurl – Again | By Parker
site.url is used in conjunction with site.baseurl when you want a link to something with the full URL to it. Success!
Read more >
Relative URL and BaseURL - Help - Jekyll Talk
When you set baseurl: "/blog" , Jekyll considers /blog/ as the root of your website. i.e. Instead of having your site served at...
Read more >
Base URL - What is Base URL? - apilayer Blog
A base URL is the continuous element of your website's address. For example, you'll notice that the address portion http://facebook.com ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found