Jump to content

Cutoff og:description to avoid html bloating


Gnuru

Recommended Posts

Posted

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....

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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