getCanonical method

getCanonical URL for the current page, this method used only with setCanonical method.

Basic Usage

The basic usage for getCanonical method is:

getCanonical(): string

Parameters

There is no parameter available for getCanonical method.

Example Usage

Usually this method called inside a layout file. Here is the basic example for getCanonical method. Here is the content of col-1.php layout file.

<!DOCTYPE html>
<html>
<head>
  ...
  <link rel="canonical" href="<?=rtrim(rtrim($this->getCanonical(),'/'),'/amp').'/'?>">
  ...
</head>
<body>
  ...
</body>
</html>

This example for querying canonical url for use with AMP HTML page.