The link code contains the address href="contacts/": it works from the homepage, but from /catalog/item/ it opens /catalog/item/contacts/. The browser resolved the relative link from the current directory. Compare the href in the code with the full URL that results on the homepage and on a product page.
Why the path depends on the open page
MDN describes different ways to resolve relative URLs, including from the current directory and from the site root. Official documentation.
At /catalog/item/, the string contacts/ is usually appended to the current base directory, not the site root. That is why a link that worked on the homepage starts opening a nested, nonexistent path. First, check the address of the open page after redirects and inspect <base> in the head. The resulting URL depends on them. Don’t fix the nonexistent /catalog/item/contacts/ by creating another copy of the contacts page: that only masks an error in the shared menu. The shared menu link should lead to the intended contacts page in the current language from the homepage, category, and product page.
Relative path, root path, and full URL
| href type | How the browser builds the URL | What to change | Which address to check |
|---|---|---|---|
| contacts/ from the homepage | Relative path | Check how it is resolved | Expected contacts page |
| contacts/ from a product page | Deep base path | Find the incorrect path | Not nested contacts |
| /contacts/ | Path from the root | Check the language and base | Correct host |
| Absolute URL | Host is specified explicitly | Check the environment | Not staging |
Compare the written and computed href
Find the link element and compare getAttribute("href") with its href property. Then open the computed address in a new tab. If it returns 404, separately check the correct contacts page to confirm that the resource exists. Check whether the link changes after client-side navigation: the component may compute it from the current router path. Also check the base in the head. The error may be in the link data, the resolution method, or a later DOM update. If the href in the CMS is incorrect, replace it there. If a script changes the correct address, fix the menu component.
Calculate the address with an example
Using the example base https://example.com/catalog/item/, compare new URL("contacts/", base).href with new URL("/contacts/", base).href. The first address remains nested; the second starts at the root of that host. Then use the base https://example.com/ru/catalog/ and see which option preserves the language. You can perform this calculation separately from the live interface. A Russian page may require contacts at /ru/contacts/, while /contacts/ will reset the language. Choose the intended path and use one function to build it across all internal menus.
You can calculate these two addresses in the browser console:
const base = "https://example.com/catalog/item/";
[new URL("contacts/", base).href, new URL("/contacts/", base).href];Results: /catalog/item/contacts/ and /contacts/ on example.com. On the page, check document.baseURI: the base tag may specify a different domain. The command only calculates the addresses.
Fix the link in the shared menu
Fix the source of the href in the shared component or CMS settings. If the menu gets its route from a directory, check the value itself rather than adding a click handler on top of the incorrect link. Preserve standard navigation, the option to open a new tab, and keyboard accessibility. In a framework, use its designated link component and make sure its rendered HTML contains the correct href. After the change, open the same component on different pages. Replacing the link only on a product page won’t fix the footer and menu if they still generate incorrect relative destinations.
Account for the language and base tag
If base points to another host, a leading slash is still resolved against that host. So the advice to “add /” needs to be checked against the full base. In a multilingual application, the URL-building function must account for the selected language. In an application published in a subdirectory, the domain root may differ from the product root. List these cases before making a change. An absolute production URL also shouldn’t be copied to staging without understanding its purpose. Check the Russian and English sections, and the test and production domains. One link-building function should produce the correct path in each case.
Open the contacts page from three pages
The link from the homepage, category, and product page leads to the intended contacts page. After client-side navigation and a reload, the result is the same; the language and domain are preserved. Fixing the shared component doesn’t require creating copies of the contacts page at the incorrect paths.
Read also: Site architecture: URL silo structure and click depth and HTML validation: why check the code and how to fix errors. Site checks are available on the reChecker technical audit page.