I have a Jekyll blog using the Minimal Mistakes theme. It's hosted through GitHub Pages, with a custom domain name. The github repo is called eg me.github.io
. Currently, the blog is at something like http://www.example.com
, so each post comes up like http://www.example.com/trouble-with-urls/
.
I want to change it so that it's all at http://www.example.com/blog
instead. I have added baseurl: "/blog"
to my _config.yml
file and now the posts are at the right place, http://www.example.com/blog/trouble-with-urls/
. However, I now have two problems: all my image links are broken, and more importantly the links to individual posts are also broken.
Is it possible to automatically redirect posts? I looked at the jekyll-redirect-from
gem, but I don't really understand it. It looks like the baseurl is automatically included in the path for the redirect_from:
and I can't work out how to ignore it. The readme for that gem says, for customising, "Simply create a layout in your site's _layouts directory called redirect.html." Is there something I can do with that?
Actually I would also like to change the permalinks as well, to add dates, but I'm trying to focus on one problem at a time! Eventually the final URL of each post should be like http://www.example.com/blog/2021/02/13/trouble-with-urls/
.
For the images, they are currently all hardcoded like 
. I can fix the path by adding in "/blog", to make it 
but I think this might be a bad way to link images anyway. I saw that there are {% %}
tags for links but can't find any resources about using them for images. Is it possible?