A good website folder structure keeps your home page (index.html) in the top-level folder, your other pages next to it or in a few clearly named subfolders, and your stylesheets, scripts and images in their own folders such as css, js and images. Use lowercase file names with hyphens instead of spaces, and link between files with relative paths. A tidy structure makes your site easier to edit, less likely to break when uploaded, and simpler to move to a new host.
This guide shows a simple layout that works for most sites, explains file naming rules, and walks through how relative paths work so your links and images keep working.
A simple folder structure that works for most sites
For a small business or personal site with up to a few dozen pages, this layout is hard to beat:
mysite/(the root folder, which you upload to your host's public folder)mysite/index.html(home page)mysite/about.html,mysite/services.html,mysite/contact.htmlmysite/css/style.css(the main stylesheet)mysite/js/main.js(any scripts)mysite/images/(photos, logos and icons)mysite/files/(PDFs and other downloads, if you have any)
Optional files that belong in the root are favicon.ico or another favicon file, robots.txt and sitemap.xml. See how to create a sitemap.xml for the last one.
When to use subfolders for pages
Once a site grows, group related pages into folders. A blog might live in blog/, and each service could have its own page in services/. A neat trick is to give each section its own index.html: then services/index.html opens when someone visits /services/, which gives you short, clean addresses.
Keep the depth shallow. Two levels of folders is plenty for most sites, and deeper nesting makes paths longer and easier to get wrong.
Why the home page is called index.html
When a visitor asks for a folder rather than a specific file, such as example.com/, the web server looks for a default file to send. On most servers that file is index.html (some also accept index.htm or index.php). If your home page is called home.html, visitors may see an error, a list of files, or your host's placeholder page instead.
File naming rules that prevent problems
Many web servers run on systems where file names are case sensitive, so About.html and about.html are two different files. A link that works on your Windows PC can fail online because Windows ignores case. Follow these rules and you avoid most of that trouble:
- Use lowercase only:
contact.html, notContact.HTML. - Use hyphens between words:
our-team.html. Avoid spaces, which become%20in addresses. - Stick to letters, numbers and hyphens. Avoid characters such as
&,#,?and accented letters. - Make names descriptive:
red-brick-patio.jpgtells you more thanIMG_4021.JPG. - Be consistent with extensions: pick
.htmlor.htmand.jpgor.jpeg, then stick with your choice.
How relative paths work
A relative path describes where a file is compared with the page that links to it. Relative paths keep working when you move the whole site to a new host or test it on your PC, which is why they are the best choice inside your own site.
| Path | Meaning | Example |
|---|---|---|
about.html | A file in the same folder as this page | Linking from index.html to about.html |
images/logo.png | A file inside a subfolder | Showing the logo from a page in the root |
../css/style.css | Go up one folder, then into css | Loading the stylesheet from blog/first-post.html |
/css/style.css | Start from the site's root folder | Works on the live server, but may not when you open files directly from your PC |
The two dots (..) mean "the folder above this one". So a page inside blog/ needs <img src="../images/logo.png" alt="Company logo"> to reach the shared images folder.
Never link to a file on your own computer, such as C:\Users\you\Pictures\photo.jpg. It may look fine on your PC, but nobody else can see it. This is one of the most common reasons for images not showing on a website.
Moving and renaming without breaking links
Every time you move or rename a page or image, every link pointing to it needs updating, and so do the relative links inside a moved page. On a ten-page site that might mean editing a dozen files. Before you reorganize:
- Back up the whole site folder.
- Plan the new structure on paper first.
- Move or rename one thing at a time, then update the links that point to it.
- Run a broken link check before uploading. See how to find broken links.
- After uploading, delete the old copies from the server so they do not linger.
Moving a page also changes its public address, so links from search results and other sites to the old address will break. For important pages, consider leaving them where they are.
The easier way: a Site Explorer that keeps links in step
Apollo Editor, a Windows 10 and 11 desktop HTML editor, includes a Site Explorer that handles the fiddly parts of organizing a site folder. Your site stays a plain folder of HTML files, with no proprietary project format.
- Full file management: create new HTML, CSS and JS files and folders, and rename, duplicate, delete or move them with drag and drop.
- Automatic link updates: when you rename or move a page, it asks, then updates the internal links for you.
- Relative path management for links and images, so new links are written correctly from each page's location.
- Broken link detection and a visual navigation tree of your site's structure.
It can also create a sitemap and manage site-wide CSS. See the feature list or the quick start for more.
Frequently asked questions
Why is my home page called index.html?
Web servers look for a default file such as index.html when someone visits a folder, so it opens without the file name in the address.
Should I use spaces in web file names?
Avoid them. Use lowercase letters, numbers and hyphens, such as about-us.html, because many servers treat file names as case sensitive.
What happens to links if I move a page into another folder?
Relative links in and to that page can break. Use an editor that updates internal links when you move or rename pages.
