Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML Build a Blog with Jekyll and GitHub Pages Building and Customizing the Blog Creating and Accessing Custom Variables

How do you add multiple images to the post and customize the location of each image?

How do you add multiple images to the post and customize the location of each image?

Leandro Incetta
Leandro Incetta
6,106 Points

One common solution is to create a folder in the root of the project directory called something like assets or downloads, into which any images, downloads or other resources are placed.

Then, from within any post, they can be linked to using the site’s root as the path for the asset to include.

Again, this will depend on the way your site’s (sub)domain and path are configured, but here some examples (in Markdown) of how you could do this using the site.url variable in a post.

Including an image asset in a post:

… which is shown in the screenshot below: ![My helpful screenshot]({{ site.url }}/assets/screenshot.jpg)

Linking to a PDF for readers to download:

… you can [get the PDF]({{ site.url }}/assets/mydoc.pdf) directly.

Link using just the site root URL: You can skip the {{ site.url }} variable if you know your site will only ever be displayed at the root URL of your domain. In this case you can reference assets directly with just /path/file.jpg.

Source: http://jekyllrb.com/docs/posts/#including-images-and-resources