In a page template (.phtml) file, we can generate a link to another CMS page
using the following snippet:
<a href="<?php echo $this->getUrl('my_page_url_key');?>">Link to my page</a>
But is it possible to have a link generated if we know the ID of the page? Example:
<a href="<?php echo $this->getUrl(3);?>">Link to my page with ID 3</a>
This way the admin can change url key without breaking the theme links.
$page = $this->pageRepository->getById($pageId); $url = $page->getIdentifier();
which I will try.