-
Notifications
You must be signed in to change notification settings - Fork 483
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 support for generating meta tags. #1991
Conversation
OpenGraph and Twitter meta-tags are generated to enable link previews.
Can we fallback to the logo if the preview image isn't found? |
@mortenpi suggested not having a fallback because the preview doesn't look the best (see #1321 (comment)), but it'd be an easy change either way! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more things:
- One last thing that would be nice is to have a couple of small
occursin
tests, mostly to make sure that the conditional behaviors are handled correctly. - It could use a CHANGELOG entry.
However, other than changing it to be an argument to HTML
and the CHANGELOG, this looks great as is. Everything else is just bikeshedding.
Made all of the suggested changes! I can also add this test preview image to the real documentation for Documenter.jl if you'd like: (*Note that even if I add it, it will only start showing up as a preview image with the next stable release of Documenter.jl, due to how the preview image URL is constructed from the canonical URL.) |
Have tested that this actually works with the documentation site for PDDL.jl: https://juliaplanners.github.io/PDDL.jl/dev/ You can enter the URL above into metatags.io to check, or just inspect the meta tags of the generated docs for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I can also add this test preview image to the real documentation for Documenter.jl if you'd like:
I you don't mind, that would be awesome. We can merge as soon as that is done.
Co-authored-by: Morten Piibeleht <[email protected]>
Done! |
Thanks! |
This PR addresses issue #1321 by adding support for generated meta tags.
As discussed in that issue, OpenGraph and Twitter meta-tags are generated to enable link previews. The following functionality is provided:
og:image
andtwitter:image
meta tags.preview.{png,webp,gif,jpg,jpeg}
in theassets
directory. Because meta tags need to link an absolute URL, the canonical URL for the image is constructed from thecanonical
option in theHTML
constructor.og:title
andtwitter:title
with the same page_title value that gets used in the<title>
tag.og:description
andtwitter:description
meta tags with a string.makedocs
, and can be over-ridden in a page-specific manner using theDescription
keyword in an@meta
-block.og:url
andtwitter:url
metatags with the canonical URL of that page, as long ascanonical
is set.Documentation has been updated accordingly. The only thing I haven't done is write test cases for this functionality, because I'm not quite sure where to add them or how to test for the existence of the correct meta-tags in some generated HTML file. Advice would be appreciated!