I'm using history.pushState() to show a URL that indicates the dynamic content (an article) currently displayed.
If I return to my home page (index.html) after looking at some dynamic content and then try to visit another page other than index.html, my nav links become broken.
On mysite.com/articles whenever a new article is chosen I call history.pushState(null, null, '/articles/' + <articleID>);. This works correctly as I'd expect. The displayed URL becomes mysite.com/articles/articleID.
Current Behavior:
At this point, if I click a nav link to go back to index.html the page successfully changes to index.html but the displayed URL becomes mysite.com/articles/index.html
Expected Behavior
The displayed URL should become mysite.com or mysite.com/index.
So is my problem:
- The way I'm using
history.pushState();or - The way that my navigation links are configured?