Skip to content

Commit

Permalink
CONTENTBOX-1489 #resolve
Browse files Browse the repository at this point in the history
SEO for meta data on home page, needs to follow site rules instead of page only rules
  • Loading branch information
lmajano committed Oct 24, 2023
1 parent b7a02d0 commit 1c690d4
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions modules/contentbox/models/system/CBHelper.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,11 @@ component accessors="true" singleton threadSafe {
*/
function getContentDescription(){
var oCurrentContent = "";
var metaDescription = getMetaDescription();

// If Meta Description is set Manually, return it
if ( len( getMetaDescription() ) ) {
return encodeForHTMLAttribute( getMetaDescription() );
if ( len( metaDescription ) ) {
return encodeForHTMLAttribute( metaDescription );
}

// Check if in page view or entry view
Expand All @@ -910,7 +911,15 @@ component accessors="true" singleton threadSafe {
oCurrentContent = getCurrentEntry();
}

// in context view or global
// Home Page Rules:
// - Page SEO
// - Site Description
if( isHomePage() ){
metaDescription = oCurrentContent.getHTMLDescription();
return len( metaDescription ) ? encodeForHTMLAttribute( metaDescription ) : encodeForHTMLAttribute( siteDescription() );
}

// Page/Blog Rules
if ( isObject( oCurrentContent ) ) {
// Do we have current page SEO description set?
if ( len( oCurrentContent.getHTMLDescription() ) ) {
Expand All @@ -929,18 +938,19 @@ component accessors="true" singleton threadSafe {
}

// Return global site description as metadata
return encodeForHTMLAttribute( trim( siteDescription() ) );
return encodeForHTMLAttribute( siteDescription() );
}

/**
* Get the current content metadata keywords according to SEO discovery rules
*/
function getContentKeywords(){
var oCurrentContent = "";
var metaKeywords = getMetaKeywords();

// If Meta Keywords is set Manually, return it
if ( len( getMetaKeywords() ) ) {
return encodeForHTMLAttribute( stripWhitespace( getMetaKeywords() ) );
if ( len( metaKeywords ) ) {
return encodeForHTMLAttribute( stripWhitespace( metaKeywords ) );
}

// Check if in page view or entry view
Expand All @@ -950,6 +960,14 @@ component accessors="true" singleton threadSafe {
oCurrentContent = getCurrentEntry();
}

// Home Page Rules:
// - Page SEO
// - Site
if( isHomePage() ){
metaKeywords = stripWhitespace( oCurrentContent.getHTMLKeywords() );
return len( metaKeywords ) ? encodeForHTMLAttribute( metaKeywords ) : encodeForHTMLAttribute( siteKeywords() );
}

// in context view or global
if ( isObject( oCurrentContent ) AND len( oCurrentContent.getHTMLKeywords() ) ) {
return encodeForHTMLAttribute( stripWhitespace( oCurrentContent.getHTMLKeywords() ) );
Expand Down

0 comments on commit 1c690d4

Please sign in to comment.