rafgraph / spa-github-pages

Host single page apps with GitHub Pages
https://spa-github-pages.rafgraph.dev
MIT License
3.87k stars 569 forks source link

Possible to have dynamic social media cards? #60

Open maysaleba opened 2 years ago

maysaleba commented 2 years ago

Hello, is it possible to have a dynamic social media cards when this solution is used?

I've tried using react-helmet to have custom og properties on my app but doesn't seem to work as it will only see the 404.html properties. Is there a workaround to this?

PixelatedLagg commented 1 year ago

Necro-post, but it has to do with how Github Pages serves 404.html. Since (to Github's servers) the client is requesting a non-existent page, Github's servers respond with a 404 response along with 404.html. This isn't a problem with browsers, but crawlers that social media sites use to search for OpenGraph tags give up when they reach the 404.

A solution I've seen posited is to use a meta refresh on 404.html to pray for it to substitute for a 301 or 302 status code. This didn't work for me (still haven't found a solution :<), but it might for any lurkers of this post.

Article that goes more in depth: http://www.backalleycoder.com/2016/05/13/sghpa-the-single-page-app-hack-for-github-pages/