Change the Permalink Structure & Adding Images to Jekyll Blog

Jekyll is a very simple static site generator which is natively supported by Github pages.

It’s very simple to set up and get your Jekyll blog running.

Making post permalinks SEO friendly

When I created this Jekyll blog using Github Pages, the post URLs were like:

https://deepakness.github.io/jekyll/2020/10/10/the-post-title.html

And, it is very long and isn’t very good for SEO.

After messing up a bit, finally, I found a perfect solution to make post URLs SEO friendly.

  • Open your blog folder and navigate to _config.yml file
  • Add permalink: /:title/ in a new line anywhere in the _config.yml file
  • Run bundle exec jekyll serve and push the code to your server

Done.

Now, all your posts should be able to adapt the new SEO friendly Permalink Structure.

And, now, the new post URLs of my blog are like:

https://deepakness.github.io/the-post-title/

Recommended: Add your Jekyll blog to the Google Search Console

Adding images to your Jekyll blog

There are 2 ways to add images in the Jekyll Github Blog.

  • ![Alt Text](/sample-image.png)
  • <img src="/sample-image.png">

It’s preferable to create an assets/img in the root directory of your Jekyll blog where you can put all the images and other assets.

Here’s how my Jekyll blog structure looks:

Also, it’s better to name your image files like this-is-a-sample-image (with dashes) or this_is_a_sample_image (with underscores).

Now, when creating .md files, you can use the following ways:

Method #1 (preferable)

![Alt Text](/assets/img/sample-image.png)

This is the best way to add images to your Jekyll blog, but you can go with the 2nd method below.

Method #2

<img src="/assets/images/sample-image.png">

However, it’s not a good practice to use this method, but it works as well. Since .md files get converted to static HTML pages, it works.

That’s it.

Similar Posts

Leave a Reply to Deepak K Cancel reply

Your email address will not be published. Required fields are marked *

2 Comments

  1. Any reason why you switched back to permalinks with the year, month and day of the post included?

    1. This site is not created using Jekyll. You can take a look at https://notes.deepakness.com/ which has that kind of permalink structure.