I am new in magento2. I saw many question but i can't understand flow.

can any one help me how to call cms page in anchor tag ?

I tried some code but it is not working.

<a href="<?php echo $this->getUrl('footer'); ?>">CMS PAGE LINK</a>

Thanks in advance :)

2 Answers 2


You can get url by page ID, Try this flow :-

$pageId = 1;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$cms_page_url = $objectManager->create('Magento\Cms\Helper\Page')

Add this code in phtml :-

<a href="<php echo $cms_page_url; ?>">CMS PAGE LINK</a>
  • 1
    Happy to help sir ....Happy Coding !!!!!! :) Commented Aug 28, 2017 at 19:15

In Magento2, if you want to get url then you use $block instead of $this in phtml

<a href="<?php echo $block->getUrl('footer'); ?>">CMS PAGE LINK</a>

$block->getUrl('footer') give the result like SITEURL/footer

In magento2, you want to get a CMS page url in phtml then you use

$_cmsHelper = $this->helper('Magento\Cms\Helper\Page');
$Url =$_cmsHelper->getPageUrl(PAGE_ID);

Additional Info

If you want to get a cms page url by ID then you can get In Block, Helper, Model ,controller classes then you should use inject in __construct()

protected $_pageHelper;
public function __construct(

    \Magento\Cms\Helper\Page $pageHelper,

) {
    $this->_pageHelper = $pageHelper;

public function getCmsUrl()
    retun $this->_pageHelper->getPageUrl($pageId);

Your Answer

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