1

This question already has an answer here:

How can I get the current page URL from browser ?

Actually I wants to highlight the current category Name by giving some class or id to it.So for that based on browser URL I will put some condition for adding class to current category.

How can I achieve this in magento 2 ?

marked as duplicate by Qaisar Satti, Rakesh Jesadiya, Community Jan 9 '17 at 7:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Do you want to add active class on current menu ? – Arunendra Jan 9 '17 at 6:56
2

Try this:

$this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true])

Source: Get Current URL from a PHTML - Magento 2

Not the answer you're looking for? Browse other questions tagged or ask your own question.