diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php
index 232f9df3d..0adb2add5 100644
--- a/classes/context/Context.class.php
+++ b/classes/context/Context.class.php
@@ -97,6 +97,12 @@ class Context
* @var array
*/
public $opengraph_metadata = array();
+
+ /**
+ * Canonical URL
+ * @var string
+ */
+ public $canonical_url = '';
/**
* path of Xpress Engine
@@ -2804,7 +2810,7 @@ class Context
*/
public static function setCanonicalURL($url)
{
- self::addHtmlHeader(sprintf('', escape($url)));
+ self::$_instance->canonical_url = escape($url);
}
}
/* End of file Context.class.php */
diff --git a/classes/display/HTMLDisplayHandler.php b/classes/display/HTMLDisplayHandler.php
index b790e0424..fce0ae87b 100644
--- a/classes/display/HTMLDisplayHandler.php
+++ b/classes/display/HTMLDisplayHandler.php
@@ -415,33 +415,34 @@ class HTMLDisplayHandler
if ($page_type === 'article' && config('seo.og_extract_description'))
{
$description = trim(utf8_normalize_spaces($oDocument->getContentText(200)));
- Context::addOpenGraphData('og:description', $description);
- Context::addMetaTag('description', $description);
}
else
{
- Context::addOpenGraphData('og:description', Context::getMetaTag('description'));
+ $description = Context::getMetaTag('description');
}
+ Context::addOpenGraphData('og:description', $description);
+ Context::addMetaTag('description', $description);
// Add metadata about this page.
Context::addOpenGraphData('og:type', $page_type);
if ($page_type === 'article')
{
- $document_canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
- Context::addOpenGraphData('og:url', $document_canonical_url);
+ $canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
}
elseif (($page = Context::get('page')) > 1)
{
- Context::addOpenGraphData('og:url', getFullUrl('', 'mid', $current_module_info->mid, 'page', $page));
+ $canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'page', $page);
}
elseif ($current_module_info->module_srl == $site_module_info->module_srl)
{
- Context::addOpenGraphData('og:url', Rhymix\Framework\URL::getCurrentDomainURL(\RX_BASEURL));
+ $canonical_url = getFullUrl('');
}
else
{
- Context::addOpenGraphData('og:url', getFullUrl('', 'mid', $current_module_info->mid));
+ $canonical_url = getFullUrl('', 'mid', $current_module_info->mid);
}
+ Context::addOpenGraphData('og:url', $canonical_url);
+ Context::setCanonicalURL($canonical_url);
// Add metadata about the locale.
$lang_type = Context::getLangType();
diff --git a/common/tpl/common_layout.html b/common/tpl/common_layout.html
index 5d08f452d..e6350e4c2 100644
--- a/common/tpl/common_layout.html
+++ b/common/tpl/common_layout.html
@@ -34,7 +34,8 @@
-
+
+