🚀 How to Host a Website for Free with AI & GitHub Pages – Complete Step‑by‑Step Guide 2026
Want a live website without paying a cent for hosting? In this beginner‑friendly guide, you’ll learn how to generate a full website using AI and then host it permanently for free with GitHub Pages. No credit card, no complex server setup – just your code and a few clicks.
Why AI + GitHub Pages Is a Game‑Changer 💡
Traditional web hosting costs money, requires server management, and often comes with renewal headaches. But with the combination of AI code generation and GitHub Pages, you can get a modern, professional website online in under 15 minutes – completely free, forever.
Here’s why this duo is unbeatable for beginners and pros alike:
- Zero cost: GitHub Pages offers unlimited free hosting for static sites (HTML, CSS, JavaScript). No hidden charges, no bandwidth limits.
- AI writes the code: You don’t need to know how to code. ChatGPT or similar tools can generate a complete, responsive website tailored to your needs.
- Fast and reliable: GitHub’s global CDN ensures your site loads quickly everywhere. Plus, automatic HTTPS is included.
- Version control built in: Every change you make is tracked, so you can always revert to an earlier version.
- Custom domain support: You can use your own domain (e.g.,
www.yourname.com) for a professional touch.
Whether you want a portfolio, a business landing page, or a blog, this method gives you a live URL that you can share immediately. Let’s dive into the step‑by‑step process.
Generate Your Website Code with AI 🤖
You don’t need to write a single line of code. We’ll use two free AI tools: one to create a detailed prompt, and another to turn that prompt into a full website.
- Open ChatGPT (or any advanced AI assistant) and ask it to craft a detailed prompt for the website you want. Be specific: “Write a detailed prompt for a modern, responsive portfolio website with a hero section, projects showcase, and contact form.”
- Copy the generated prompt.
- Go to a code‑generation AI like Kimi.ai, DeepSeek, or even ChatGPT with code interpreter. Paste the prompt and ask it to output a complete HTML file with embedded CSS and JavaScript.
- Review the generated code, preview it if possible, and copy the entire HTML document.
Below is an example prompt you can use immediately. Just paste it into ChatGPT to get a beautifully designed personal site.
Generate a complete, modern, mobile‑responsive portfolio website using only HTML, CSS, and JavaScript (all in one file). Include a sticky navigation bar, a hero section with a professional headline and CTA button, an about section, a projects grid with placeholder images, and a contact footer. Use a clean blue‑white color scheme, smooth scroll, and subtle animations. Output the full index.html code.
For even better results, ask the AI to follow modern design principles (glassmorphism, minimalism) and include embedded icons (like Font Awesome). The more detailed your prompt, the more polished your site will be.
Prepare Your Website Files Locally 📁
GitHub Pages requires your main page to be named index.html. Here’s how to set that up:
- Create a new folder on your computer (name it something like
my-website). - Inside that folder, create a text file and rename it to index.html. Make sure the extension is
.html, not.txt. - Open
index.htmlwith a text editor (Notepad, VS Code, or any editor). - Paste the entire AI‑generated code into the file and save.
If your site needs additional assets (images, CSS files, JavaScript files), place them all in the same folder. The AI usually embeds everything into one HTML file, so you might not need extra files.
For simplicity, ask the AI to put all CSS and JS directly inside the HTML using
<style> and <script> tags. That way you only need to upload a single file.
Create a GitHub Repository 🐙
A repository is a storage space where your website lives. To create one:
- Go to github.com and sign up for a free account (or log in).
- Click the “+” icon in the top‑right corner and select New repository.
- Give it a name (e.g.,
my-portfolio). - Set visibility to Public (required for free GitHub Pages).
- Click Create repository – don’t add any README, .gitignore, or license yet.
Your empty repository is now ready. You’ll see a screen with setup instructions; we’ll use the manual upload method next.
Upload Your Files to GitHub ☁️
Now we’ll move the index.html file from your computer to GitHub:
- On the repository page, click the link “uploading an existing file” (it appears right after the quick setup text).
- Drag and drop your
index.html(and any other files/folders) into the upload area. - Once the files appear, scroll down and click the green “Commit changes” button. You can leave the default commit message.
After a moment, your files will appear in the repository. The code is now hosted, but it’s not yet a live website. We’ll enable that next.
GitHub Pages is case‑sensitive. Make sure your file is named exactly
index.html (all lowercase). Otherwise the site won’t load automatically.
Enable GitHub Pages via Actions ⚡
GitHub Pages now uses GitHub Actions to build and deploy your site. Setting it up is easier than ever:
- Inside your repository, click the Settings tab.
- From the left sidebar, click Pages (under “Code and automation”).
- Under Build and deployment, change the Source from “Deploy from a branch” to GitHub Actions.
- A list of workflow templates will appear. Find Static HTML (or simply “HTML”) and click Configure.
- A new file will open – this is the deployment workflow. Do not edit anything. Just click the green “Commit changes…” button, then click Commit changes again to confirm.
As soon as you commit, GitHub automatically starts a deployment action. You can watch the progress by clicking the Actions tab. It usually completes in 15‑30 seconds.
It takes your raw HTML files and publishes them to a special
gh-pages branch, which is then served via GitHub’s global CDN. Every time you push new changes, the action re‑runs automatically.
Your Site Is Now Live! 🎉
Once the action finishes successfully, your website is publicly accessible. Here’s how to find the URL:
- Go back to the Actions tab. You’ll see a completed workflow with a green checkmark.
- Then return to Settings > Pages. At the top, you’ll see a message: “Your site is live at https://YOUR_USERNAME.github.io/REPO_NAME/”.
- Click the Visit site button to open it in a new tab. That’s your permanent, free website URL.
Share this link with anyone, and your site will load instantly. To update the site later, simply re‑upload a modified index.html (or push changes via Git), and the deployment action will automatically refresh it within seconds.
Bookmark the URL! You can also enable a custom domain in the next section to make it even more professional.
Optional: Connect a Custom Domain 🌐
If you own a domain (or plan to buy one), you can replace the default GitHub URL with your own, like www.yourname.com. It’s free to set up.
- In Settings > Pages, scroll down to the Custom domain section.
- Type your domain (e.g.,
www.yourname.com) and click Save. - GitHub will provide DNS verification. Then, go to your domain registrar (GoDaddy, Namecheap, etc.) and add the following DNS records:
For a subdomain like www, add a CNAME record pointing to YOUR_USERNAME.github.io. For the apex domain, use ALIAS or A records pointing to GitHub’s IP addresses (185.199.108.153, 185.199.109.153, 185.199.110.153, 185.199.111.153).
After DNS propagation (up to 24 hours), your site will be accessible via your custom domain, with automatic HTTPS. GitHub manages the SSL certificate for free.
Once the custom domain is verified, check “Enforce HTTPS” in the Pages settings. It may take a few minutes to become active.
Final Checklist & Next Steps ✅
- Generated website code using ChatGPT + AI code generator
- Saved code as
index.htmlin a dedicated folder - Created a public GitHub repository
- Uploaded
index.html(and any assets) to the repository - Enabled GitHub Pages via GitHub Actions (Static HTML template)
- Confirmed the deployment succeeded (green checkmark)
- Visited the live site at
https://username.github.io/repo - (Optional) Configured a custom domain with HTTPS
Congratulations! You now have a live website that cost you absolutely nothing. To take it further, consider adding new pages (like about.html, projects.html) and linking them from your navigation. Each time you update the code and push to GitHub, your changes go live automatically.
Key Takeaways
index.html file is all you need🚀 Ready to Launch Your Free Website?
Copy the ChatGPT prompt, generate your site, and follow the steps above. In under 15 minutes, you’ll have a professional online presence without spending a dime.


Join the tech debate...
We love a good discussion, but please keep it respectful and relevant to the topic. Vulgarity, personal attacks, and spam will be removed. Let’s keep the community smart, helpful, and welcoming to all tech fans!