When I started my blog initially, I simply uploaded images to the repository. However, When I needed to back up articles to Notion, all the images were stored as relative paths and could not be displayed correctly. This is why we need an image hosting service.
Definition of Image Hosting#
Image hosting allows users to upload, store, and share images online. The hosting website stores the images on its server, enabling you to embed images into your websites and blogs, or just share them with others.
Benefits of Using an Image Hosting Service:#
- Free storage space:
Store images on the image hosting service’s server and remove them from your own device. - Image management:
Organize your images in one place to avoid cluttered and reduce the potential impacts of changes. Even if your computer crashes, your images will still be safe. - Easy sharing:
You do not need to upload your images to Instagram or facebook; you can easily share them with anyone with your permission. - Load speed:
Improve website speed by delivering images more efficiently, which can also enhance SEO.
Image Hosting Service#
There are many image hosting websites, offering both free and paid options. You can also purchase a VPS to build your own personal image hosting service.
The bandwidth and storage requirements for personal use are typically modest. Here I use Cloudflare R2. Cloudflare R2 is an S3-compatible, zero egress-fee, object storage. The free storage plan is 10 GB / month, which meets my needs. Here is the pricing list.
Create Cloudflare R2#
Login your cloudflare account, find R2 Object Storage on the left side, and activate the R2 service. Then click create bucket button.
Fill in the bucket name as you wish, choose the location, or simply use the automatic location if you do not have sepecial requirements. Then click create bucket button.
Now we can upload images into this bucket.
Custom Domain#
The default domain of the bucket is random and not easy to remember. A Custom domain is available. Note that when a custom domain is connected to your bucket, the contents of your bucket will be made publicly accessible through that domain.
Click the settings of your bucket, input your registered domain or subdomain, connect the domain, and wait for the DNS to take effect.
When the configuration is finished, go back to your bucket’s uploading page, upload the image and, check the details.
Now You can use the URL to access this image.
Cover image: star-forming nebula W51, one of the largest “star factories” in the Milky Way galaxy. (From NASA)