public function generate($minify = false)
{
$this->loadWebMasterTags();
$title = $this->getTitle();
$description = $this->getDescription();
$keywords = $this->getKeywords();
$metatags = $this->getMetatags();
$canonical = $this->getCanonical();
$prev = $this->getPrev();
$next = $this->getNext();
$languages = $this->getAlternateLanguages();
$html = [];
if ($title) {
$html[] = "<title>{$title}</title>";
}
if ($description) {
$html[] = "<meta name=\"description\" content=\"{$description}\">";
}
if (!empty($keywords)) {
$keywords = implode(', ', $keywords);
$html[] = "<meta name=\"keywords\" content=\"{$keywords}\">";
}
foreach ($metatags as $key => $value) {
$name = $value[0];
$content = $value[1];
// if $content is empty jump to nest
if (empty($content)) {
continue;
}
$html[] = "<meta {$name}=\"{$key}\" content=\"{$content}\">";
}
if ($canonical) {
$html[] = "<link rel=\"canonical\" href=\"{$canonical}\"/>";
}
if ($prev) {
$html[] = "<link rel=\"prev\" href=\"{$prev}\"/>";
}
if ($next) {
$html[] = "<link rel=\"next\" href=\"{$next}\"/>";
}
foreach ($languages as $lang) {
$html[] = "<link rel=\"alternate\" hreflang=\"{$lang['lang']}\" href=\"{$lang['url']}\"/>";
}
return $minify ? implode('', $html) : implode(PHP_EOL, $html);
}