DEV Community

Cover image for Did you know you can add images to your GitHub Pages website for FREE without LFS or third-party image servers?
EffessDev
EffessDev

Posted on

Did you know you can add images to your GitHub Pages website for FREE without LFS or third-party image servers?

I recently found a surprisingly useful hidden feature of GitHub.

You might want images on your static GitHub Pages site, but you probably don't want to commit them directly since they would bloat your repo. You also cannot use LFS because it won't work out of the box with GitHub Pages. Even though you can use a custom GitHub Action to fetch the LFS files before deployment, that will consume your monthly LFS credits.

I have been looking into third-party image servers lately so I can upload my image there and use that link on my website. But I hadn't thought that GitHub already has one; it's just not obvious.

If you drag and drop an image file into a Markdown file in your repository on GitHub.com, you get a link to the image like this:

My website already uses Markdown for its content. So it's as straightforward as it can get, except I have to go to GitHub.com to upload my images. But I will have to do something similar if I had to use a third-party image server anyway. What I do now is edit my Markdown files from my PC, but leave placeholders for images that I later upload from GitHub.com.

Maybe it's just me who didn't think about this all the time. I was planning to add my credit card for that free tier from Cloudflare. That's when this idea popped up. It surprisingly works quite well! Just posting here hoping it might help somebody else too.

One gotcha to watch out for: Once you upload an image, you cannot easily delete it. I learned this only today.

Thanks for reading ☺️

Top comments (0)