Himanshu Joshi

← Back to Blog

How I Added Sitemap and Robots.txt to My Portfolio Website

Published on June 7, 2026 by Himanshu Joshi

When I started improving my portfolio website for search engines, I understood that only creating pages is not enough. Search engines also need a clear path to discover those pages. That is where sitemap.xml and robots.txt become useful.

My website was built using Vite and hosted as a static website. In this setup, the easiest way to add sitemap and robots files was to place them inside the public folder.

What Is Sitemap.xml?

A sitemap.xml file is a list of important website URLs. It helps search engines discover pages such as the homepage, blog page, tools page, services page, contact page, and individual blog articles.

For a growing website, sitemap becomes very helpful because every new blog article can be added to it. After updating the sitemap, it can be submitted in Google Search Console.

What Is Robots.txt?

Robots.txt is a simple text file that gives crawling instructions to search engines. For my website, I wanted search engines to crawl all public pages. So I used a simple robots.txt file that allowed all pages and pointed to the sitemap.

The file was placed at:

public/robots.txt

Where I Added These Files

In a Vite project, files inside the public folder are copied to the root of the final website. That means if I create public/sitemap.xml, it becomes available at /sitemap.xml on the live domain.

My final files were:

Why This Helped

After adding these files, I submitted the sitemap in Google Search Console. Google successfully read the sitemap and discovered my pages. This gave me confidence that the website structure was correct.

It does not mean Google will index every page immediately, but it makes discovery easier and more organized.

My Sitemap Strategy

I included only real pages in the sitemap. I avoided adding broken links, empty pages, or coming soon pages. This is important because a sitemap should represent useful and accessible pages.

Every time I publish a new blog article, I update the sitemap by adding the new article URL.

Conclusion

Adding sitemap.xml and robots.txt is a small task, but it improves the technical foundation of a website. For a portfolio website that is becoming a blog and content website, these files are important for SEO and Google Search Console setup.