Magento 2 stores the URL identifier in url_rewrite table. You can get the page entity_id or page_id by idendifier. If you look into url_rewrite table where you can search by request_path column.

Programmatically you can use the following Model Class.
/<Magento Root Directory>/vendor/magento/module-cms/Model/Page.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | protected $_page; public function __construct( ... \Magento\Cms\Model\Page $page, ... ) { ... $this->_page = $page; ... } /** * Check if page identifier exist for specific store return page id if page exists * * @param string $identifier * @param int $storeId * @return int */ $page_id = $this->_page->checkIdentifier('home', 0); if ($page_id > 0) { echo "Page Found with id : " . $page_id; }else { echo "Page Not Found"; } |
It will return 2 which is the default page id for home page.