jwillmer / jekyllDecent

Blog Template for Jekyll
http://jwillmer.github.io/jekyllDecent/
MIT License
133 stars 123 forks source link

URLs appear twice on site deployment #30

Closed svanimisetti closed 7 years ago

svanimisetti commented 7 years ago

I tried forking the base repo and changing the project setting to serve GitHub pages from master branch. I updated the 'url' variable in _config.yml file. The 'baseurl' variable is empty. I can see the site firing up - but the URLs are all doubled-up. When I browse to the main site, I see the same behavior. Is this a problem with my browser? I am using Google Chrome Version 56.0.2924.87 (64-bit).

jwillmer commented 7 years ago

Hi, I see the problem, it is also happening on the auto generated GitHub page of this blog template. I think GitHub is using a new Jekyll version that works differently as before. I will investigate and fix it.

jwillmer commented 7 years ago

I created a bug report at Jekyll: https://github.com/jekyll/jekyll/issues/5908

pathawks commented 7 years ago

The problem is with the way you are building URLs.

The problem went unnoticed before jekyll/github-metadata#76 because your baseurl is empty, but now that it is being set automatically the links are broken.

site.github.url apparently contains the full URL to the site, and you do not need to use baseurl at all if this is how you'd like to build URLs.

If you want to use site.url instead, you will have to flip your prepend statements. If baseurl is /jekyllDecent and site.url is http://jwillmer.github.io (and this is what they are when GitHub builds the site):

{{ "/css/screen.css" | prepend: site.url }} will give us http://jwillmer.github.io/css/screen.css If we try to prepend the baseurl to that ({{ "/css/screen.css" | prepend: site.url | prepend: site.baseurl }}), we end up with /jekyllDecenthttp://jwillmer.github.io/css/screen.css. A browser will resolve this URL as http://jwillmer.github.io/jekyllDecenthttp://jwillmer.github.io/css/screen.css

I would suggest using the absolute_url filter instead, as it takes care of this complexity for you.

jwillmer commented 7 years ago

Thank you for your help and detailed error description @pathawks. I commited the changes and it looks like all references are fixed now.

jwillmer commented 7 years ago

Now it finally works as intended and I also used this bug to refactore some url patterns.