Relative URLs in Jekyll

Found this great resource that explains how to create dynamic paths when linking your images in your layouts: https://travis.media/how-to-add-images-in-jekyll-posts-with-relative-links

The layouts were in _layout directory but the images are in images directory. Since the pages using the layout are also organized in different directories, the   path would change based on where the .html was located. Because of this, the images were breaking because the path to the file kept changing depending on where in our project directory the .html existed.

To prevent this issue, using {{site.github.url}} loads the images correctly.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s