How to Get the Magento CMS Page Identifier of the Current Page

To get the URL key / identifier of any CMS page in Magento, use the following bit of code.

<?php

$cmsPageUrlKey = Mage::getSingleton('cms/page')->getIdentifier();

?>

This will return the path that comes after the website’s URL. For example, the URL identifier for the About Us page might be about-us and not the full URL like http://www.yourwebsite.com/about-us/. If you want the full URL including your website address, then you should use the following piece of code.

<?php

$cmsPageUrl = Mage::getUrl() . Mage::getSingleton('cms/page')->getIdentifier();

?>