Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my Jekyll site show HUGE icons on Github Pages

  1. I generated a new jekyll site with jekyll new simple-site
  2. The site looks ok in the localhost. It's the default, dummy site that's generated anyways.
  3. I pushed it to gh-pages branch of a repo.

Now the site shows up under github.io/ but with HUGE icons.

The svg icons for github and twitter in the default jekyll generated site span the whole width of the page. They should be 16px or so.

Similarly 3 huge blocks appear in the top. They, again, are svg, which are supposed to be thin lines.

Here's my site: http://ananthp.github.io/carnatic_scores/
(repo: https://github.com/ananthp/carnatic_scores/tree/gh-pages )

HUGE svg icons in github pages jekyll site

like image 596
Ananth Pattabiraman Avatar asked Sep 13 '14 05:09

Ananth Pattabiraman


2 Answers

As your site is not at the root of the domain ananthp.github.io/ but in a "directory" carnatic_scores/, you have to set baseurl variable in your _config.yml file.

baseurl: '/carnatic_scores'

Edit: some explanations

In _includes/head.html you can see this :

<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">

which is equivalent to

<link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">

With baseurl set to "" (default) your relative url is /css/main.css, which is resolved as http://ananthp.github.io/css/main.css by your browser = 404 not found.

With baseurl set to "/carnatic_scores" your relative url is /carnatic_scores/css/main.css, which is resolved as http://ananthp.github.io/carnatic_scores/css/main.css by your browser = your cool css !

That's true for all assets (css, js and image) :

<script src="{{ site.baseurl }}/path_to_scripts/script.js"></script>

<img src="{{ site.baseurl }}/path_to_images/image.jpg">

or in markdown

![Image alt]({{ site.baseurl }}/path_to_images/image.jpg)
like image 131
David Jacquel Avatar answered Sep 27 '22 22:09

David Jacquel


David Jacquel's answer is correct but I wanted to point out that Jekyll has a page about how to properly setup your Jekyll site for github pages. On that site they specifically talk about the fix (changing baseurl) but they mention other important things that you have to know too such as previewing your site with

$ jekyll serve --baseurl ''

Good luck and happy blogging!

like image 29
KCE Avatar answered Sep 27 '22 22:09

KCE