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 meta tags to docs.python.org #65

Closed
Mariatta opened this issue Oct 5, 2022 · 6 comments
Closed

Add meta tags to docs.python.org #65

Mariatta opened this issue Oct 5, 2022 · 6 comments

Comments

@Mariatta
Copy link
Member

Mariatta commented Oct 5, 2022

We need to add <meta> tags to the output of sphinx documentation.

It looks like this is supported using the meta directive

https://docutils.sourceforge.io/docs/ref/rst/directives.html#meta

Example:

.. meta::
   :description: The reStructuredText plaintext markup language
   :keywords: plaintext, markup language

Some meta tags we should have:

  • title
  • description

Some advice according to: https://ahrefs.com/blog/seo-meta-tags/

Title meta:

  • Write a unique title tag for each page;
  • Be brief, but descriptive;
  • Avoid generic and vague titles;
  • Use sentence case or title case;
  • Create something click-worthy—not clickbait;
  • Match search intent;
  • Include your target keyword where it makes sense;
  • Keep it under 60 characters.

Description meta:

  • Write a unique description for each page;
  • Try to summarize content accurately;
  • Avoid generic descriptions;
  • Use sentence case;
  • Create something click-worthy, not clickbait;
  • Match search intent;
  • Include your target keyword where it makes sense;
  • Keep it under 160 characters
@Mariatta
Copy link
Member Author

Mariatta commented Oct 5, 2022

I think this is where we could get expert advice on what to write inside the title and description meta tags.

@ezio-melotti
Copy link
Member

I don't think we should add them manually, but use an extension to automate the creation instead.

sphinxext-opengraph already does this for OGP meta tags (including automatically setting the title and description), but apparently not for regular meta tags. I haven't checked yet if there are other extensions that can add those, if not, we can create one similar to sphinxext-opengraph or make a PR against it to add this feature (if they are interested).

See also:

@hugovk
Copy link
Member

hugovk commented Oct 6, 2022

sphinxext-opengraph already does this for OGP meta tags (including automatically setting the title and description), but apparently not for regular meta tags. I haven't checked yet if there are other extensions that can add those, if not, we can create one similar to sphinxext-opengraph or make a PR against it to add this feature (if they are interested).

They're interested, there's a feature request to add <meta name="description">: wpilibsuite/sphinxext-opengraph#65).

@Mariatta
Copy link
Member Author

Mariatta commented Oct 6, 2022

The extension looks interesting. Looking at the comments, it seems like we can probably use the ogp_custom_meta_tags?

@hugovk
Copy link
Member

hugovk commented Oct 18, 2022

We can't use ogp_custom_meta_tags because they would be hardcoded for all pages, and we'd like them generated for each page.

They're interested, there's a feature request to add <meta name="description">: wpilibsuite/sphinxext-opengraph#65).

I've created a PR for this: wpilibsuite/sphinxext-opengraph#71.

@hugovk
Copy link
Member

hugovk commented Aug 4, 2023

Description meta tags have now been added by python/cpython#99931.

For example, https://docs.python.org/3/library/sys_path_init.html has:

<meta property="og:title" content="The initialization of the sys.path module search path" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/library/sys_path_init.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="A module search path is initialized when Python starts. This module search path may be accessed at sys.path. The first entry in the module search path is the directory that contains the input scrip..." />
<meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="A module search path is initialized when Python starts. This module search path may be accessed at sys.path. The first entry in the module search path is the directory that contains the input scrip..." />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />

See also #63 (comment).

@hugovk hugovk closed this as completed Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants