How to get cms page title and page content in custom template file

I tried below code to display title but its not working

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
 echo $objectManager->create('\Magento\Cms\Model\PageFactory')->load('contact-us', 'identifier')->getTitle();

1 Answer 1


You can try below code to get CMS page title.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$ModelPageFactory = $objectManager->create('\Magento\Cms\Model\PageFactory');
$page_title = $ModelPageFactory->create()->load('home')->getTitle();

Not recommended to use object manager. You can make the dependency as added

use Magento/Cms/Model/PageFactory;

protected $pageFactory;

public function __construct(...,PageFactory $pagefactory,...) {
$this->pageFactory = $pageFactory;

public function loadCMSPage() {
$page = $this->pageFactory->create()->load(<PAGE URL OR ID HERE>);

Your Answer

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

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