Move Your GitHub Pages Index HTML: A Step-by-Step Guide

Ann Jul 09, 2026

Ever felt the need to move your GitHub Pages' index.html to a different location? You're not alone. This guide will walk you through the process, ensuring your website remains functional and visually appealing.

Host Websites Free with GitHub Pages ๐Ÿš€๐Ÿ’ป
Host Websites Free with GitHub Pages ๐Ÿš€๐Ÿ’ป

Before we dive in, let's understand why you might want to change the location of your index.html. Perhaps you've decided to restructure your project, or maybe you're migrating from another platform. Whatever the reason, this guide will help you navigate the process smoothly.

the screenshots are showing how to check out their email and what to do with them
the screenshots are showing how to check out their email and what to do with them

Understanding GitHub Pages Directory Structure

First, let's grasp the default directory structure of GitHub Pages. By default, your index.html file is located in the root directory of your repository. This is because GitHub Pages serves the index.html file in the root of your repository by default.

Get Started With GitHub Pages (Plus Bonus Jekyll)
Get Started With GitHub Pages (Plus Bonus Jekyll)

However, you can change this behavior by creating a specific file in your repository. This file, named CNAME, tells GitHub Pages to serve a different file as the index. But what if you want to change the location of your index.html itself? That's where our guide comes in.

Moving index.html to a Subdirectory

Modern GitHub Profile UI
Modern GitHub Profile UI

Let's say you want to move your index.html to a subdirectory named 'my-website'. Here's how you can do it:

1. Create a new folder named 'my-website' in your repository. This will be the new location for your index.html.

2. Move your index.html file into the 'my-website' folder.

How to Publish Website on Github Pages in Three Simple Steps
How to Publish Website on Github Pages in Three Simple Steps

3. Create a new file named '.nojekyll' (with a leading dot) in the root directory of your repository. This file tells GitHub Pages not to ignore your index.html file.

Moving index.html to a Different Repository

If you want to move your index.html to a different repository, the process is a bit more involved:

the github chat sheet is displayed in this screenshote screen graber
the github chat sheet is displayed in this screenshote screen graber

1. Create a new repository on GitHub where you want to move your index.html.

2. Push your index.html file (and any other files you want to move) to the new repository.

Github Cheatsheet
Github Cheatsheet
GitHub ยท Change is constant. GitHub keeps you ahead. Amazing Travel Destinations, Software Engineer, Video Footage, Cloud Based, Software Development, Software, Coding
GitHub ยท Change is constant. GitHub keeps you ahead. Amazing Travel Destinations, Software Engineer, Video Footage, Cloud Based, Software Development, Software, Coding
the differences between github and git is shown in this graphic above it
the differences between github and git is shown in this graphic above it
An Apple-style layout focuses on clarity, spacing, and logical hierarchy, making your content
An Apple-style layout focuses on clarity, spacing, and logical hierarchy, making your content
How to have a Free Website on GitHub | ู…ูˆู‚ุน ุงู„ุฅู„ูƒุชุฑูˆู†ูŠ ู…ุฌุงู†ูŠ
How to have a Free Website on GitHub | ู…ูˆู‚ุน ุงู„ุฅู„ูƒุชุฑูˆู†ูŠ ู…ุฌุงู†ูŠ
a screen shot of a web page with the words'html input types '
a screen shot of a web page with the words'html input types '
My GitHub Account
My GitHub Account
the differences between github and github in web design, which one should use?
the differences between github and github in web design, which one should use?
login form html css
login form html css
the git chatsheet screen is lit up with orange and green text on it
the git chatsheet screen is lit up with orange and green text on it
Embedding Images in HTML using <img>
Embedding Images in HTML using <img>
the github chat sheet is displayed in pink and black
the github chat sheet is displayed in pink and black
How to Create a Github Page for Your Project
How to Create a Github Page for Your Project
two screens showing different types of webpages and the same one with words on them
two screens showing different types of webpages and the same one with words on them
Git & GitHub Explained for Beginners (2026)
Git & GitHub Explained for Beginners (2026)
Hands-on: GitHub for Windows takes the pain out of using git
Hands-on: GitHub for Windows takes the pain out of using git
the new rendering engine page for an upcoming game is shown in this screenshote
the new rendering engine page for an upcoming game is shown in this screenshote
an image of a web page with the text structure in red and white on it
an image of a web page with the text structure in red and white on it
How to Get Your Site Online for Free With Github Pages - Learn to Code With Me
How to Get Your Site Online for Free With Github Pages - Learn to Code With Me
the different types of html tags are shown in this screenshote screen graber
the different types of html tags are shown in this screenshote screen graber

3. Go to your old repository's settings and disable GitHub Pages. This will stop GitHub from serving your old index.html file.

4. Go to your new repository's settings and enable GitHub Pages. This will start serving your new index.html file.

Testing and Troubleshooting

After moving your index.html, it's crucial to test your GitHub Pages site to ensure everything works as expected. Here are a few things to check:

1. **URL Structure**: Ensure your URLs are correct and that your site is accessible at the new location.

2. **Internal Links**: Check that all internal links on your site point to the correct URLs. This is especially important if you've moved your site to a new repository.

3. **Relative Paths**: Ensure that any relative paths in your HTML, CSS, or JavaScript files are correct. They should now be relative to the new location of your index.html.

If you encounter any issues, double-check that you've followed the steps correctly. If you're still having trouble, don't hesitate to reach out to the GitHub community for help.

Changing the location of your index.html can seem daunting, but with the right steps, it's a manageable task. Whether you're restructuring your project or migrating to a new repository, this guide has equipped you with the knowledge you need to make the move successfully. Happy coding!