Question

My site hosts a large quantity of information with categories/subcats/sub-subcats (tabs) and then info divided into questions and answers in accordion format.

I would like to have a different title tag and/or URL for each level

E.g. Animals/reptiles/snakes/how-do-you-catch-a-snake (how do you catch a snake is an accordion heading).

Is this possible?

Was it helpful?

Solution

Multiple <title> tags are not allowed, but you could modify the document.title property using javascript. For example, this would work:

$('#animals, #reptiles, #snakes, #how-do-you-catch-a-snake').click(function(e) {
    //assuming selected tabs get a .selected class
    if (!$(this).hasClass('selected')) {
        $(this).addClass('selected');
        //Assuming you want to make the `<title>` the same as the tab's contents
        document.title = this.innerHTML;
    } else {
        $(this).removeClass('selected');
    }
});

That makes a whole bunch of assumptions, but without code provided, I can't really give you a more fitting code. This should give you a general idea about how this could work though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top