Skip to main content
Topic: Open Graph (Read 2314 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Open Graph

This is a reminder to me to add the meta tags in the default theme for this. A few lines will make social sharing look a hell of a lot better.

Code: [Select]
<meta property="og:url" content="{{this url}}" />
<meta property="og:sitename" content="{{ board name }}" />
<meta property="og:type" content="article" /> <!-- or person for profiles -->
<meta property="og:title" content="{{ subject }}" />
<meta property="og:description" content="{{ snip 250 characters of the message }}" />
<meta property="og:image" content="{{ get the first attachment image or the site header }}" />

Re: Open Graph

Reply #1

https://github.com/joshuaadickerson/Elkarte/commit/48c16306273834e5b54ad8612079f6020ef32c64

I am not sure how I will get the description or the image for topics. Profiles should work without issue but I don't have a public forum to test it on. Hopefully someone can give it a shot or just try patching this forum?

Re: Open Graph

Reply #2

I don't see anyway to seed a description other than the the first x characters of the text which may or may not be available at that point.  Only thing we have for the image would be the site logo.

Either way I do agree that open graph info needs to be available and this is a good start

 

Re: Open Graph

Reply #3

I don't think this is something to do right now (maybe 1.2?) but it's the best way I can think of to handle a lot of common uses...

1) finally add the subject to the topics table: varchar(255)
2) add a description field to the topics table varchar(255) which is up to 255 bytes of the first message and strip all of the BBC

The alternative is a theme setting where display would fetch the topic's first message's subject and description unless $_GET['msg'] then use that. We could also just get the first message for the current page, but I don't like that as much since it isn't really the topic's subject, description. It might be the image.

The only way I can think of doing it without getting the first message is to loop through each of the db results. We don't have to assign anything to a variable at that time but it means another loop of the result. I think that might require some performance testing.