Assuming your URL matches the following home/section/page.html , you can use this function at the top of any page and set a title based on the URL if that is what you mean.
function setTitle(extra) { document.title = location.pathname.split('/').map(function(v) { return v.replace(/\.(html|php)/, '') .replace(/^\w/, function(a) { return a.toUpperCase(); }); }).join(' | ') + (extra && ' | '+ extra); }
Using this function, a header similar to this will be generated: Home | Section | Page Home | Section | Page Home | Section | Page . If you want to add certain things for a specific page, then pass the line as an extra parameter, and it will be added to the header, i.e.
// url: http://mypage.com/home/about/frogs setTitle('Frogs are awesome'); console.log(document.title); //=> Home | About | Frogs | Frogs are awesome
source share