Open tmfrnz opened 4 years ago
This is tricky with the current site architecture - when social media sites attempt to generate preview content for a post, they look for specific Open Graph <meta>
tags in the initial HTML served by the site server when they access a particular URL (i.e. https://rightstracker.org/en/country/NZL?as=hi). In our case, we have a single (minimal) initial HTML file that is served for all our relevant URL's, and Javascript subsequently loads on the user's browser to populate that HTML with all the content that we eventually see per page. That single initial HTML file currently just has the generic content (title, image etc - i.e. https://rightstracker.org/hrmi-og.png) built in.
So what we want is some way for our server to respond with a specific HTML file with relevant Open Graph <meta>
tags when specific URL's are requested by the social media sites. There's a couple of ways we might go about this:
index.html
we currently use) that are served for those related URL's (i.e. https://rightstracker.org/en/country/NZL?as=hi would send back a custom HTML page with NZL-specific <meta>
tags). This is just a bit of manual work, but how much depends on how many pages in the site need their own content - is it just the 200-ish country pages?<meta>
tags needed to generate the previews. I used this approach for https://gwrc.2050calculator.nz/calculator where there was a similar need for custom content for sharing - see here for the server code, and here for the kind of redirects to facilitate that. The Rights Tracker currently uses a node server, which means this approach should be doable (though IMO a server doesn't seem to be necessary, and this approach would 'lock in' using a server), as long as the preview content can be accessed by the server when a page URL is requested (which I'd assume it can).I realise that's probably a lot to parse... basically I'd probably suggest option 3 might be the easiest in the short-term, but ideally IMO we'd move to option 1 in the future (but probably as part of a larger piece of work towards not using a node server and pre-building all the pages). I'd estimate around a day's work to get it going (so 6-8 hours), depending a bit on which pages need custom preview content and what that content is, and how Firebase handles redirects (I haven't looked into that yet).
Thanks @iainkirkpatrick. As you guessed, this is beyond my technical ability to comment on. However, I wonder if - rather than taking a comprehensive approach to this - we focus only on the option to share the country pages and rights pages (which are the ones Thalia shares the most) and have the social media preview content be the photo or icon image that is shown at the top of each of those pages, along with some very basic text from the top of the page?
See also related discussions on react-helmet (the library we use to update each view's meta information), including some options
Currently the site only produces a generic preview and the dedicated preview image is sometimes not showing.
Meta/preview information (title, description and image) should be dependent on the specific page