jekyll: Css not loading even locally
gem install jekyll bundler
jekyll new my-awesome-site
cd my-awesome-site
bundle install
bundle exec jekyll >> 3.2.1
bundle exec jekyll serve
When visiting 127.0.0.1, I have a 404 on http://example.com/css/main.css.
Digging in minima/_includes/head.html
code, I’ve found this :
{% assign custom_url = site.url | append: site.baseurl %}
{% assign full_base_url = custom_url | default: site.github.url %}
<link rel="stylesheet" href="{{ "/css/main.css" | prepend: full_base_url }}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: full_base_url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title | escape }}" href="{{ "/feed.xml" | prepend: full_base_url }}">
Is appending site.url
better than simply appending base.url
? For now, this breaks user experience.
First, I have to understand the bug. I do, but many users will have some difficulties to get it.
And now, if I want to watch my site locally, I have to set url to 127.0.0.1 and if I want to send to production on another server than gh-pages, I have to set the production url in order to get my assets loaded.
In good old times, setting base.url
was the only thing to do to get it working both locally and in production. url was the production server url and that was ok.
Hiding things in order to simplify user’s life ? I don’t buy gem based templates.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 16 (12 by maintainers)
Commits related to this issue
- Hack to fix failure of local serve Minima 1.2.0 had a breaking change related to github.url See jekyll/jekyll#5352 Minima 2.0.0 will resolve once GitHub Pages upgrades. — committed to DES37/slides by spencermathews 8 years ago
- Hack to fix failure of local serve Minima 1.2.0 had a breaking change related to github.url See jekyll/jekyll#5352 Minima 2.0.0 will resolve once GitHub Pages upgrades. — committed to DES37/slides by spencermathews 8 years ago
- Hack to fix failure of local serve Minima 1.2.0 had a breaking change related to github.url See jekyll/jekyll#5352 Minima 2.0.0 will resolve once GitHub Pages upgrades. — committed to DES37/slides by spencermathews 8 years ago
Thanks for reporting @djacquel.
I can reproduce the behaviour. It’s because of the default
site.url
value in_config.yml
. So by default it will generate a 404 error trying to look for http://example.com/css/main.css We can agree that this is not the best way to introduce Jekyll to a new user. 😞I believe this has been addressed in https://github.com/jekyll/jekyll/pull/5338
cc @jekyll/core @ashmaroli
Could we add some tests to prevent default theme rendering to be broken?
@ashmaroli please don’t start posting that on every ticket, that is uncessary and it’ll spam me and other maintainers with redundant messages, that’s unacceptable.
Why is there no change on this annoying bug ? 3 weeks since the breaking change was made and nobody noticed it ? Did someone (except @DirtyF) goes to Stack overflow ? Many people have problems with this.
@ashmaroli it’s never too late to add an info note. On http://jekyllrb.com/docs/quickstart/ to maximize the chances new users see it ?
This has been brought up on IRC@#jekyll a few times, and indeed a poor out-of-box experience. Unless the user has experience, comprehension, etc. they are stuck trying to figure out why their site is “broken”.
@djacquel the
new-theme
option will provide for a base/starting point to build themes from.