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 ?

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

Try this:

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

Source: Get Current URL from a PHTML - Magento 2

| improve this answer | |

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