When you traverse between pages of website, you have a link to indicate the current page you are on. So dynamically finding which links is to be set active is done by the below article. Please read the article below for better understanding.
There are many primitive ways of doing it but this seems correct as its DRY and KIS.
Subscribe to Engineering At Kiprosh
Get the latest posts delivered right to your inbox