Skip to main content
Version: Fegg 5.x

Sitemap::__construct

Create an empty sitemap

Description​

public Sitemap::__construct( [ string $baseUrl = '' ] )

$baseUrl is the root URL that paths are added to. '' uses the URL of the current request (FEGG_CURRENT_URL: the scheme, the host and the base path).

Arguments​

NameData typeDefaultRemarks
$baseUrlstring''Root URL of the site, with the base path. '': the current request

Example​

Controller
use Fegg\Tool\Sitemap;

$sitemap = new Sitemap(); // URLs of the current host
$sitemap = new Sitemap('https://www.example.com'); // always the production host

Pass the root URL when the sitemap is written outside a request (a command that saves it as a file).