You are looking for Single Page Applications (SPA).
The page does not reload at any point in the process, nor does control
transfer to another page, although the location hash can be used to
provide the perception and navigability of separate logical pages in
the application, as can the HTML5 pushState() API.
To answer your question, basically, the steps are:
- Prevent page redirect.
- Update browser state (simulating the new page).
- Dynamically load the related content.
Superficially, should be like:
var linkAbout = document.querySelector('a[href="/about"]');
linkAbout.addEventListener('click', function (e) {
// Prevent page redirect.
e.preventDefault();
// Update browser state.
var stateObj = { foo: "bar" };
history.pushState(stateObj, 'About page', '/about');
// Dynamically load the related content.
// Here you will need to send some asynchronous (ajax) request
// to the server, get the content and put it on the current page.
var container = document.querySelector('#container');
var content = getContent('/about');
container.innerHTML = content;
});
Obviously this is a summary and there are many things about this approach that was not mentioned here.
You can find many libraries and frameworks that can help to build web apps by using this modern approach.