Planning the Site: A Sitemap, Navigation and the Click Depth of Every Page
Plan the structure of a site before building it: list pages, draw the links as a graph, compute how many clicks it takes to reach each page, find orphan pages, and verify the numbers with two independent searches.
In this lesson you will
- Plan pages and navigation first
- Model a site as a graph
- Compute click depth for every page
- Find orphan and buried pages
About 28 minutes
The pages Priya needs, and how people reach them
Priya started building by choosing colours and fonts, and after a week had eleven pages and no clear idea of how they fit together. A site is easier to build, and much easier to use, when you plan it first on paper: what pages exist, what each one is for, and how a visitor gets from one to another. The plan is a sitemap, a list or tree of pages. It starts from the visitors’ tasks, not from the owner’s organisation: see the candles, find the price, read about delivery, contact Priya, order. Each task should be possible in a few clicks from the home page.
Mathematically a website is a graph: pages are nodes and links are arrows between them. The click depth of a page is the smallest number of clicks needed to reach it from the home page, and a breadth-first search finds it: first the home page at depth 0, then every page it links to at depth 1, then the pages those link to at depth 2, and so on. Two problems show up in the result. A page with no way to reach it from the home page is an orphan: visitors and search engines cannot find it. And a page buried more than three clicks deep is hard to reach, and search engines may treat it as unimportant. Navigation menus put the main pages at depth 1, so a good menu is a short list of the most important pages, and footers carry the legal and support pages.
| Concept | Meaning |
|---|---|
| Sitemap | The plan of pages and their relations |
| Click depth | Fewest clicks from the home page |
| Orphan page | No path from the home page |
| Main menu | Pages at depth 1 |
| Breadcrumb | Shows the path back up |
const links = {
home: ['candles', 'about', 'delivery', 'contact', 'blog'],
candles: ['lavender', 'pine', 'honey', 'gift-sets'],
lavender: ['care-guide'], pine: [], honey: [], 'gift-sets': ['corporate-orders'],
about: ['press'], delivery: ['returns'], contact: [], blog: ['post-1', 'post-2'],
'post-1': ['post-2'], 'post-2': [], 'care-guide': [], 'corporate-orders': [], press: [], returns: [],
'old-promo': ['candles'], 'secret-landing': [],
};
function depths(start) {
const d = { [start]: 0 }, queue = [start];
while (queue.length) { const p = queue.shift(); for (const q of links[p] || []) if (!(q in d)) { d[q] = d[p] + 1; queue.push(q); } }
return d;
}
const d = depths('home');
const pages = Object.keys(links);
const orphans = pages.filter(p => !(p in d));
const deep = pages.filter(p => d[p] > 2);
const byDepth = {};
Object.entries(d).forEach(([p, k]) => (byDepth[k] = byDepth[k] || []).push(p));
Object.keys(byDepth).forEach(k => console.log('depth ' + k + ':', byDepth[k].join(', ')));
console.log('orphans (no path from home):', orphans.join(', '));
console.log('deeper than 2 clicks:', deep.join(', '));
console.log('DATA ' + JSON.stringify({ d, orphans, deep, n: pages.length }));
depth 0: home
depth 1: candles, about, delivery, contact, blog
depth 2: lavender, pine, honey, gift-sets, press, returns, post-1, post-2
depth 3: care-guide, corporate-orders
orphans (no path from home): old-promo, secret-landing
deeper than 2 clicks: care-guide, corporate-orders
The sample site has 18 pages. The home page is at depth 0, its five menu pages (candles, about, delivery, contact, blog) are at depth 1, and everything else is deeper: the three candle pages, the gift sets, the press page, the returns page and the two blog posts are at depth 2. Two pages are deeper than two clicks: the care guide and the corporate orders page, both at depth 3, reached through the lavender candle and the gift sets. If corporate orders are an important business line for Priya, hiding them at depth 3 is a design mistake that the numbers expose, and the fix is a link from the home page or the menu.
Two pages are orphans: old-promo and secret-landing. The old promotion page links to the candles page, but nothing links to it, so it exists on the server and nobody can reach it by clicking, unless they have the address. Orphans are common after redesigns, and they are a security concern as well when they hold old prices or private content. The remedies are to link the page, redirect it or delete it. Notice that the blog post 2 is reachable in one more way, from post 1, but its depth is still 2, because the shortest path counts.
Independent check: the depths were computed a second time with a different algorithm, in Python: not a queue-based breadth-first search but repeated relaxation of the links, in the manner of the Bellman-Ford method, which keeps improving the best known distance of each page until nothing changes. It gives the same depth for all 16 reachable pages, the same two orphans and the same two deep pages. A graph this size could be checked by eye, and with a hundred pages the program becomes the only practical way, and some builders and crawlers can export the link structure of a real site for exactly this analysis.
Check by hand: home links to candles, about, delivery, contact and blog, so those are 1. Candles links to the three candles and the gift sets, all 2. The care guide is reached by home, candles, lavender, care-guide, which is 3 clicks. The old promotion and the secret landing page appear in no list of links from reachable pages, so they have no depth at all.
If a page matters to the business, such as prices or contact, put it in the main menu. Visitors rarely dig more than two or three clicks for something they are not sure exists.
Write each page on a note, group them, and move them until a visitor’s task takes a few clicks. It takes ten minutes and saves days of rebuilding in the tool.
Builders, plans and prices change often, so the lessons use generic labels such as Builder A and describe categories of tools, and you must check each vendor’s current website for features, prices and limits. Every calculation and check in this lesson was run while the course was written, in Python 3.13 or Node.js 22, on sample data that the lesson provides, with a second independent calculation. Some builders show a site map view and can list pages with no links to them. Check what yours offers.
Practice
Draw the sitemap for a site you want to build, with 8 to 12 pages, and compute the click depth of each by hand. Add a “gift-guide” page and decide where to link it. List the pages of an existing site and find any orphans.
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
What is a sitemap?
- A list of keywords
- A photo gallery
- A plan of the pages and how they relate
- A server
Plan before building.
What is click depth?
- The size of a page
- The fewest clicks from the home page to a page
- The number of images
- The loading time
Breadth-first search finds it.
What is an orphan page?
- A page with no text
- A page that no link leads to
- A page with one image
- The home page
Visitors cannot find it.
Where should the most important pages be?
- At depth 1, in the main menu
- Deep in the footer
- Hidden
- On the last page
Short paths.
Why compute depth with a program?
- Large sites are too big to check by eye
- Programs are always right
- Browsers require it
- It changes the design
And verify it with a second method.
Summary
- Plan pages from visitors’ tasks.
- A site is a graph; click depth is the shortest path from the home page.
- Find orphans and buried pages.
- Keep the main menu short.
Questions
How many pages should a small business site have?
As few as needed to serve the visitors' tasks, often five to ten. More pages mean more to maintain and keep up to date.
What is a footer for?
For pages that people need occasionally, such as the privacy policy, terms, delivery and returns, contact details and social links.
Do I need a sitemap file as well?
A sitemap.xml file helps search engines discover pages, and many builders create one for you. Lesson 6 covers it.
