How should I create the link to internal page in a template file ?

For instance, I have a subcategory which URL key is education, how should it be called in my phtml file to get the page http://my.website.com/education.html ?

I'm currently using this:

<a href="<?php echo $block->getUrl('education.html') ?>">

1 Answer 1


As I understand you are trying to get subcategory url with url key . here is solution - Define objectmanager in your block-

$category = $block->_objectManager->create('Magento\Catalog\Model\Category')

 $url = $category->getUrl(); 


use it like this


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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