-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Consider supporting OpenGraph? #1758
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
Comments
Seems like a great addition. It should be trivial to implement on our theme overrides. Does implementing this as an article type make sense, or is there another type that would work best for something like the DIscourse onebox? |
Yes, article type makes sense. I think "og:description" will be the trickiest tag to get right - it along with "og:title" contain the text which is actually shown in the onebox. According to this, most sites will display between 200 and 300 characters of the og:description value, so it essentially is a 200-character summary of the doc page. |
Yeah, I'm not entirely sure how to handle the description. The change for the meta tags is a simple addition to the template overrides RTD maintains. We do have access to the content of the page in the templates, but it's HTML, which rules out a simple truncation operation inside the templates. If we want to be more intelligent about the content truncation, we'll have to write a template filter in a Sphinx extension to break up the HTML content. For now, this might just be the project description field in the RTD project admin, instead of per-page content for the description.
|
That sounds good. And maybe set og:image to the project logo whose name is somehow exposed to the template. As a concrete reference, here's what the meta tags for say http://docs.julialang.org/en/release-0.4/manual/variables/ could maybe end up looking like: <meta property="og:title" content="Variables" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://docs.julialang.org/en/release-0.4/manual/variables/" />
<meta property="og:site_name" content="readthedocs: Julia" />
<meta property="og:description" content="The Julia programming language.." />
<meta property="og:image" content="http://docs.julialang.org/en/release-0.4/_static/julia-logo.svg"/> |
If we ever start collecting the project logo, that would be another good addition. Currently we aren't collecting that and don't have a great way to determine that outside of project configuration options. This reference seems like a reasonable place to start at least |
I was able to do a POC here, injecting all the metatags on the rtd theme https://github.com/rtfd/sphinx_rtd_theme. I was able to make work: title, site_name, url, type, description, image and locale (this one isn't on the same format of But, there is a design decision to take here, we depend on the So, should this live on the rtd-theme or on the rtd-sphinx-extension? |
I was able to do the |
At least on twitter it makes a LOT of o difference 😁 https://cards-dev.twitter.com/validator |
I think that our sphinx extension will be better since it will affect all the themes that are built on Read the Docs, not only our own. Also, I think that we may sanitize the description probably to make it looks nice (without We may want to use the default Read the Docs logo if we don't have a project's image ( |
I'd say no logo if the user hasn't specified. It seems odd to brand with our logo |
So, another thing to point out is that Sphinx already has support for this natively through reST Ultimately, I want opengraph enabled across all projects. If we are hard coding the template, we'll probably break or at least override anyone using I haven't looked at how sphinx handles this, but my assumption is that the meta elements will be in the doctree after parsing the source, so we can use an extension to add default meta tags based on RTD context data to each document. http://docutils.sourceforge.net/docs/ref/rst/directives.html#meta |
@agjohnson so, I was editing the extension, with the doctree and everything, but I hit a bug that makes impossible to do the meta tag default thing https://sourceforge.net/p/docutils/bugs/281/, doctutils doesn't support So, another option is using the builder I guess? I didn't try but, I guess we have access to the dom |
Sphinx issue sphinx-doc/sphinx#2645 |
We inject a template already https://github.com/rtfd/readthedocs-sphinx-ext/blob/8e545547c2c1324368406a710dd76e0534674499/readthedocs_ext/readthedocs.py#L117-L121, but I'll try to look if we can have the dom, or block this till the problem is resolved in sphinx |
Another sphinx related issue sphinx-doc/sphinx#6089 |
This is already fixed on docutils, but it's not released yet. It will be on 0.15: http://docutils.sourceforge.net/RELEASE-NOTES.html#release-0-15b-dev |
This is not blocked anymore 🎉 |
Any update on this? |
Yeah, I'd agree we don't want to install this for users. Documenting this extension would be a good first step. I'd still like to have this as a feature across all of RTD hosted docs though, not just on some projects. I would leave this issue open because of that. |
Would this mean RTD would inject into the users HTML output or build? Would this conflict with sphinxext-opengraph or would it be a documentation only approach? This seems to conflict with @stsewd |
@Daltz333 I'm not sure why I was @'ed, as I have not participated in this discussion. |
My bad, autocorrect on phone github |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The original request was about supporting OpenGraph for sites hosted on Read the Docs by injecting some magic for our users. Now, sphinxext-opengraph exists, users can adopt it if they want, and we are moving away from injecting extensions for users. Therefore, I propose we close this issue and open a new one (or discuss internally) on which RTD-owned projects do we want to adopt this extension. |
We should still document this solution in our docs as a guide. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
After our experience with https://github.com/readthedocs/blog/, to support OpenGraph on Read the Docs people need to
The rest is automatic, since sphinxext-opengraph does some magic if the project is hosted on Read the Docs, as explained in https://github.com/wpilibsuite/sphinxext-opengraph#options. I think this would be quite short for a guide, but if folks still think it would be useful, I will be happy to write it. |
@astrojuanlu In case a guide does not quite fit here, I remember that we talked about collecting a collection of Sphinx's extensions and recommend them with a small config file ready to use. If we still want to go in that direction, we could use https://sphinx-extensions.readthedocs.io/ for that. |
We have expressed elsewhere that usually we don't recommend third-party extensions in our docs (see for example discussion at #8396), so I think we should close this issue and continue the discussion on humitos/sphinx-extensions#14. On a related note, I think we should give https://sphinx-extensions.readthedocs.io/ more attention and visibility. |
Yeah I agree, this might make more sense as an official RTD project even However, if we are pointing users towards another project for this sort of content, seems like something would could also include as narrative content in our own docs. Perhaps guide content is the best avenue for this sort of guidance. There is a lot of room for us (or Sphinx, but historically us) to highlight how to solve these specific customer/user issues when authoring documentation with Sphinx. Sphinx-extensions helps with illustration, but guide content would probably help translate problem -> solution more for customers/users -- for example, translate "how do I author documentation with multiple code examples" -> "you can use sphinx-tabs, copybutton, ..." etc. |
I'm happy to move to the
When I created the project, I didn't want to generate too much written content due to the lack of time. I'd like to keep each page simple if possible so we can highlight extensions quicker without the need of writing a full guide about it. |
Yeah this seems fine, it might be helpful to have two separate overviews of extensions -- narrative, describing why or how authors could solve a particular problem with an extension, and illustrative, showing how each extension functions with the sphinx-extensions repo. The two seem complimentary for now |
I just wanted to comment here that If you are interested in opengraph, you should follow that repository since it's the right extension to install in your documentation. |
As discussed here, OpenGraph support would allow Discourse forums and other popular systems to display inline previews of links to readthedocs pages, especially useful for forums about programming languages and tools.
It just takes a few
<meta>
tags injected into the rendered HTML, so I don't think it should be too burdensome. Plus Jeff Atwood himself is pushing for it :)The text was updated successfully, but these errors were encountered: