Repository navigation
Add OpenGraph meta tags - #385
Conversation
|
How about tagging |
|
That can be done. Any suggestion for a description? "Bowse mods for {{ game.name }}", or keep the default one? |
|
No, I don't know what to put in the description. I would kind of expect to see something generic like the number of mods available for that game, but I don't think we have that easily available, and it's not important enough to work on adding it. |
We do, actually! Going with "Browse {{ mod_count }} mods for {{ ga.name }}" then. |
c262026 to
4b21a7e
Compare
HebaruSan
left a comment
There was a problem hiding this comment.
Great idea, should help SpaceDock enter the twenty-first century.
Started working on this yesterday, and funnily enough today @V1TA5 suggested it in the Discord.
Background
This pull request adds HTML meta tags according to the Open Graph protocol to SpaceDock.
These tags are used by websites and programs to generate "embeds" / "cards" / previews of a shared link.
Among those are Discord, Facebook and Element (Matrix client).
Twitter requires their own custom meta tags, AFAIK. We can think about adding them too, once we've confirmed this works as intended.
Open Graph only defines the declaration of meta tags, it does not define how they should be interpreted, used and rendered. This means that every software/service shows them a bit differently.
Right now there already is a single Open Graph tag present, which sets an image to display in the preview:

Better than nothing, but there's much more you can do with Open Graph:
Changes
In
layout.html, the base of all our HTML pages, a newopengraphblock is defined. It contains a bunch of default tags, like the site name as title, the existingog.pngas image, and a new configurablecaptionas description.These tags can be overwritten as necessary in all pages, by redefining the
opengraphblock.Right now I have set custom meta tags for mod pages (
mod.html), mod packs (mod_list.html), and profiles (view_profile.html). See below for example images.We can add some more page-specific tags later, but I'd like to test these first. And I think I got the most relevant.
There's one tag that is outside of the block in
layout.html, so that it can not be overridden, which is theog:site_nametag. The site name should stay the same regardless of page.A new
captionkey is added to theconfig.ini. I've set it to a string I found infrontend/static/opensearch.xml, it was better than anything I could come up with. And is there a better word than "caption"?I've also sorted the keys in
config.inia bit, roughly by area which they configure.Deployment notes
Whenever this is deployed onto a new system (alpha, beta, production), a
captionkey should be set inconfig.ini.Suggestion:
Images
As rendered by Discord. Click to expand
And an updated image for mods, now with mod and game version moved into description:

And an image for game pages:
