mike icon indicating copy to clipboard operation
mike copied to clipboard

Social share preview doesn't work when sharing `http://project.example.com` instead of `http://project.example.com/latest`

Open pekkaklarck opened this issue 4 months ago • 3 comments

Social share preview is controlled by meta tags such as description and og:image that Material for MkDocs social plugin can generate. When using mike, they don't work if you share a URL pointing to the project root like http://project.example.com, because the /index.html generated by set-version doesn't contain these meta tags. Only the target page contains them, so when sharing something like http://project.example.com/latest everything works fine. At least I prefer sharing shorter URLs so preview not working is a bit annoying.

Luckily the situation is easy to fix by copying relevant meta tags from /latest/index.html (or whatever is the default version) to /index.html. As an example, you can see the index.html file or the project I'm setting up. After these changes the preview works fine as seen here.

Although fixing the issue manually is easy, it would be great if set-default would copy the relevant meta tags automatically. It would have two main benefits:

  • Everything would work fine automatically when versioning is set up. Users didn't need to think about this.
  • It would be possible to run set-default again later if information has changed. Possibly mike could even keep /index.html it has generated updated automatically.

If this isn't considered worth the effort, adding a note about the problem to mike's docs would be good. Then those who care could fix their /index.html manually.

pekkaklarck avatar Oct 08 '24 15:10 pekkaklarck