I say I have a section of a page like this (rough HTML to give an idea):
www.mydomain.com/contact-us
<div class="regional-offices">
<div class="south-west">
<a href="#south-west">South West</a>
<div class="south-west-content">South west office address</div>
</div>
<div class="north-east">
<a href="#north-east">North East</a>
<div class="north-east-content">North east office address</div>
</div>
...
...
Currently, these are a set of accordions that expand to show the content when the link is clicked. What I would like to do is treat them as individual URLs so that they can be seperately indexed by Google, as of course at the moment they are just part of a single page.
I have been researching the History API and can see how I would do this as far as creating unique URLs for each section, but where my understanding falls down is how Google or other search engines will handle these links if the required info is already part of the page and not stored at its own seperate URL.
For instance, the first step would be to change the <a>
tag to be something like:
<a href="/contact-us/north-east">North East</a>
We can then use JS to preventDefault()
going directly to the URL, and instead provide the user with an expanded accordion, bring the page scroll down to the accordion and a unique URL using the History API. This is all well and good if we visit the URL directly, or click any of the links.
But the problem is that as far as I know, the Google crawler will try to follow the link and be faced with a 404 because there's no Javascript preventing access to the resource in the URL. And nor do I want there to be.
Or is it the case that I will need a unique location holding the contents of the accordion, which is indexable, and also pulled in with AJAX when a collapsed accordion is interacted with?
Apologies if I haven't made anything clear.