How to Add Images to GitHub Pages

Ann Jul 09, 2026

Adding images to your GitHub Pages can significantly enhance the visual appeal and comprehensibility of your content. Here's a step-by-step guide on how to achieve this.

Embedding Images in HTML using <img>
Embedding Images in HTML using <img>

Before we dive in, ensure you've already set up your GitHub Pages repository. If not, you can follow GitHub's official guide to create one.

Modern GitHub Profile UI
Modern GitHub Profile UI

Preparing Your Image

Before uploading, make sure your image is optimized for web use. This involves reducing its file size without compromising quality. Tools like TinyPNG or Squoosh can help with this.

Host your personal application for free in github
Host your personal application for free in github

Also, ensure your image has a descriptive filename and alt text. Alt text is crucial for accessibility and SEO. It describes the image for visually impaired users and helps search engines understand your image's content.

Image Formats

a laptop computer sitting on top of a wooden desk next to a cup of coffee
a laptop computer sitting on top of a wooden desk next to a cup of coffee

GitHub Pages supports several image formats, including PNG, JPG, and GIF. However, JPG is generally recommended for photographs, while PNG is better for graphics with transparent backgrounds.

For animated GIFs, use them sparingly as they can slow down your page loading time.

Image Size

GitHub - annotorious/annotorious: Add image annotation functionality to any web page with a few lines of JavaScript.
GitHub - annotorious/annotorious: Add image annotation functionality to any web page with a few lines of JavaScript.

While there's no strict size limit, keep your images under 8MB for optimal performance. Also, consider the dimensions. Images that are too large or small may not display as intended.

For GitHub Pages, images with a width of around 600-800 pixels usually work well. You can adjust the size further using CSS.

Uploading and Linking Your Image

How to Host a Website for Free Using GitHub Pages
How to Host a Website for Free Using GitHub Pages

Now that your image is ready, let's upload it to your GitHub Pages repository.

First, navigate to your repository on GitHub. Click on the '+' icon in the top-right corner and select 'Create new file'. Name the file with a descriptive, lowercase name, including the file extension (e.g., 'my-image.jpg').

How to Add Pictures to a Video
How to Add Pictures to a Video
Add Watermark To Images In HTML Javascript
Add Watermark To Images In HTML Javascript
Add text to photos with Picfont
Add text to photos with Picfont
How to Add Diagrams to GitHub Markdown Files
How to Add Diagrams to GitHub Markdown Files
ITS SO FUN THERES SO MANY FILTERS AND OPTIONS TO TRY
ITS SO FUN THERES SO MANY FILTERS AND OPTIONS TO TRY
GitHub - John-Davidson-8/smilga-background-images-project: Learn how to add images as background and use linear gradient. Also simple navbar and button.
GitHub - John-Davidson-8/smilga-background-images-project: Learn how to add images as background and use linear gradient. Also simple navbar and button.
How To Add Text To A Picture Or Photo In 8 Easy Free Ways
How To Add Text To A Picture Or Photo In 8 Easy Free Ways
someone is playing an interactive video game on their tablet pc with the caption how to turn images into pings
someone is playing an interactive video game on their tablet pc with the caption how to turn images into pings
Push Your Local Project to GitHub: Git Setup Guide for Beginners
Push Your Local Project to GitHub: Git Setup Guide for Beginners
CSS image slider
CSS image slider
3D Image Gallery in Pure CSS
3D Image Gallery in Pure CSS
How to Create an Impressive GitHub Profile README
How to Create an Impressive GitHub Profile README
Create Image Accordion Slider With HTML CSS And JavaScript
Create Image Accordion Slider With HTML CSS And JavaScript
GitHub - DidierMurilloF/animal-animation-app: This is a simple Shiny app that lets you create your own custom animal animation by clicking on different animal images. Each time you click on an animal, a heart will appear and the selected animal will be added to the list below. You can add up to five animals to the list, and each animal will appear with its own heart.
GitHub - DidierMurilloF/animal-animation-app: This is a simple Shiny app that lets you create your own custom animal animation by clicking on different animal images. Each time you click on an animal, a heart will appear and the selected animal will be added to the list below. You can add up to five animals to the list, and each animal will appear with its own heart.
#CSS Animations Tips and Tricks
#CSS Animations Tips and Tricks
How to Automate Your GitHub Profile README
How to Automate Your GitHub Profile README
How to Add a Watermark to Your Photos: 5 Different Ways
How to Add a Watermark to Your Photos: 5 Different Ways
an image with the caption's description below it, which appears to be from google
an image with the caption's description below it, which appears to be from google
I tried using a free tool 'chaiNNer' that can set the processing contents of the image in a daisy chain and execute complex processing in one shot Review
I tried using a free tool 'chaiNNer' that can set the processing contents of the image in a daisy chain and execute complex processing in one shot Review
GitHub Copilot
GitHub Copilot

Uploading the Image

In the file name field, type a brief description of the image, then click 'Commit new file' at the bottom. This will create a new file in your repository.

Now, drag and drop your image into the file editor, or click 'Upload files' to select it from your computer. Once uploaded, click 'Commit changes' at the bottom.

Linking the Image

To display the image on your GitHub Pages, you'll need to link it from your markdown file. In your repository, navigate to the markdown file where you want to insert the image.

Use the following syntax to link your image: `![Alt Text](https://your-username.github.io/your-repo-name/your-image-name.jpg)`. Replace 'Alt Text' with your image's alt text, 'your-username' with your GitHub username, 'your-repo-name' with your repository's name, and 'your-image-name' with the name of your image file.

Displaying the Image

Once linked, your image should display correctly on your GitHub Pages. However, you might want to adjust its size or alignment. You can do this using CSS.

To add CSS, create a new file named 'styles.css' in your repository's root directory. In this file, you can define styles for your image. For example, to set the width to 50% and align it to the left, you would write:

```css img { width: 50%; float: left; } ```

Remember to link this CSS file to your markdown file using the following syntax at the top: ``.

That's it! You've successfully added an image to your GitHub Pages. Keep experimenting with different images, sizes, and styles to make your pages engaging and visually appealing.