Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenGraph tags to playlist page head #3078

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

MonkeyDo
Copy link
Member

@MonkeyDo MonkeyDo commented Dec 13, 2024

These were requested on the forums, now that we have Atom feeds for playlists and the embedded previews that use OG tags look very generic.

Followed docs at https://ogp.me/#type_music

My initial implementation used react-helmet (which we already use for the purpose of modifying head tags), but unfortunately that means the page must first load and run the react app before the tags are modified/added.

The solution required moving back to the flask/jinja template layer as those will be rendered to HTML directly.

I've modified our main index.html jinja template to support known and arbitrary opengraph tags, with sane defaults (same as before this PR) for title, description and type.

Once we have images for playlist thumbnails, we could consider adding that as og:image tags and testing that out.

Here is the resulting head when loading a playlist page:
image

N.B.: Considering LB is now a single-page-app with routing on the client-side, the opengraph tags rendered by flask will stay there even after you navigate to another page where (some of) those tags don't apply. This is not really an issue, as the meta tags are meant to be parsed by a machine once on page load while the client-side navigation is all about users in their browser page.

These were requested on the forums now that we have Atom feeds for playlists, and the embedded previews that use OG tags look very generic.
Forgot the indentifier in the playlist is a fully qualified URL, not just the ID
@pep8speaks
Copy link

pep8speaks commented Jan 8, 2025

Hello @MonkeyDo! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2025-01-08 17:22:39 UTC

We need to add OG meta tags *before* the react page is loaded (at which point react-helmet can take over) as the tags are read on page load in a lot of cases.

This system should allow us to add any arbitrary og: meta tag we want on various pages as needed, with sane defaults for existing OG tags such as og:type, og:description and og:title as we have them until now.
@MonkeyDo MonkeyDo force-pushed the playlist-opengraph-tags branch from 8adb168 to e240a66 Compare January 8, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants