yii\helpers\BaseUrl::canonical PHP Method

canonical() public static method

The canonical URL is constructed using the current controller's [[\yii\web\Controller::route]] and [[\yii\web\Controller::actionParams]]. You may use the following code in the layout view to add a link tag about canonical URL: php $this->registerLinkTag(['rel' => 'canonical', 'href' => Url::canonical()]);
public static canonical ( ) : string
return string the canonical URL of the currently requested page
    public static function canonical()
    {
        $params = Yii::$app->controller->actionParams;
        $params[0] = Yii::$app->controller->getRoute();
        return static::getUrlManager()->createAbsoluteUrl($params);
    }