Jump to content

Cutoff og:description to avoid html bloating


Gnuru
 Share

Recommended Posts

when using pages and adding some articles, the og:description holds the whole article and bloats the html page.

I would suggest to use only max 200 characters for the description.

E.g. in the includeMeta Template I use this code:

{{foreach \IPS\Output::i()->metaTags as $name => $content}}
	{{if $name != 'title'}}
		{{if is_array( $content ) }}
			{{foreach $content as $_value }}
				<meta {{if mb_substr( $name, 0, 3 ) === 'og:'}}property{{else}}name{{endif}}="{$name}" content="{{substr($_value,0,strpos($_value, ' ', 200));}}">
			{{endforeach}}
		{{else}}
			<meta {{if mb_substr( $name, 0, 3 ) === 'og:'}}property{{else}}name{{endif}}="{$name}" content="{{$trc=substr($content,0,200);}}$trc">
		{{endif}}
	{{endif}}
{{endforeach}}

But I'm not really firm with coding....

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...