I would like to generate a link like this:
<a href="http://example.com/my-custom-page">My link</a>
Target page: example.com/my-custom-page.
Template: module-customer/view/frontend/templates/form/register.phtml
First, use cms page to create new page with identifier is your_custom_page_link
.
In your phtml file, use this code: <a href="<?php echo $this->getUrl('your_custom_page_link') ?>">Link label</a>
First you need to add dependency in your related block
public $_storeManager;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
.....
) {
...
$this->_storeManager=$storeManager;
}
public function getCustomUrl($customUrl){
return $this->_storeManager->getStore()->getBaseUrl() . $customUrl;
}
Add in your template below code:
echo $block->getCustomUrl('my-custom-page');
Router.php
or make Controller file will needed path