You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sphinx extension to generate [Open Graph metadata](https://ogp.me/).
6
7
7
8
## Installation
8
9
9
-
`python -m pip install sphinxext-opengraph`
10
+
```sh
11
+
python -m pip install sphinxext-opengraph
12
+
```
10
13
11
14
## Usage
12
15
Just add `sphinxext.opengraph` to your extensions list in your `conf.py`
@@ -17,9 +20,9 @@ extensions = [
17
20
]
18
21
```
19
22
## Options
20
-
These values are placed in the conf.py of your sphinx project.
23
+
These values are placed in the `conf.py` of your Sphinx project.
21
24
22
-
Users hosting documentation on Read The Docs *do not* need to set any of the following unless custom configuration is wanted. The extension will automatically retrieve your site url.
25
+
Users hosting documentation on Read The Docs *do not* need to set any of the following unless custom configuration is wanted. The extension will automatically retrieve your site URL.
23
26
24
27
*`ogp_site_url`
25
28
* This config option is very important, set it to the URL the site is being hosted on.
@@ -32,12 +35,14 @@ Users hosting documentation on Read The Docs *do not* need to set any of the fol
32
35
*`ogp_image_alt`
33
36
* This is not required. Alt text for image. Defaults to using `ogp_site_name` or the document's title as alt text, if available. Set to `False` if you want to turn off alt text completely.
34
37
*`ogp_use_first_image`
35
-
* This is not required. Set to True to use each page's first image, if available. If set to True but no image is found, Sphinx will use `ogp_image` instead.
38
+
* This is not required. Set to `True` to use each page's first image, if available. If set to `True` but no image is found, Sphinx will use `ogp_image` instead.
36
39
*`ogp_type`
37
-
* This sets the ogp type attribute, for more information on the types available please take a look at https://ogp.me/#types. By default it is set to `website`, which should be fine for most use cases.
40
+
* This sets the ogp type attribute, for more information on the types available please take a look at [https://ogp.me/#types](https://ogp.me/#types). By default it is set to `website`, which should be fine for most use cases.
38
41
*`ogp_custom_meta_tags`
39
42
* This is not required. List of custom html snippets to insert.
40
-
43
+
*`ogp_enable_meta_description`
44
+
* This is not required. When `True`, generates `<meta name="description" content="...">` from the page.
[Field lists](https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html) are used to allow you to override certain settings on each page and set unsupported arbitrary OpenGraph tags.
71
+
[Field lists](https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html) are used to allow you to override certain settings on each page and set unsupported arbitrary Open Graph tags.
66
72
67
73
Make sure you place the fields at the very start of the document such that Sphinx will pick them up and also won't build them into the html.
68
74
69
75
### Overrides
70
-
These are some overrides that can be used, you can actually override any tag and field lists will always take priority.
76
+
These are some overrides that can be used on individual pages, you can actually override any tag and field lists will always take priority.
71
77
72
78
*`:og_description_length:`
73
-
* Configure the amount of characters to grab for the description of the page. If the value isn't a number it will fall back to `ogp_description_length`. Note the slightly different syntax because this isn't directly an OpenGraph tag.
79
+
* Configure the amount of characters to grab for the description of the page. If the value isn't a number it will fall back to `ogp_description_length`. Note the slightly different syntax because this isn't directly an Open Graph tag.
74
80
*`:og:description:`
75
81
* Lets you override the description of the page.
82
+
*`:description:` or `.. meta::\n :description:`
83
+
* Sets the `<meta name="description" content="...">` description.
76
84
*`:og:title:`
77
85
* Lets you override the title of the page.
78
86
*`:og:type:`
@@ -95,7 +103,7 @@ Page contents
95
103
```
96
104
97
105
### Arbitrary Tags[^1]
98
-
Additionally, you can use field lists to add any arbitrary OpenGraph tag not supported by the extension. The syntax for arbitrary tags is the same with `:og:tag: content`. For Example:
106
+
Additionally, you can use field lists to add any arbitrary Open Graph tag not supported by the extension. The syntax for arbitrary tags is the same with `:og:tag: content`. For example:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse at lorem ornare, fringilla massa nec, venenatis mi. Donec erat sapien, tincidunt nec rhoncus nec, scelerisque id diam. Orci varius natoque penatibus et magnis dis parturient mauris.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse at lorem ornare, fringilla massa nec, venenatis mi. Donec erat sapien, tincidunt nec rhoncus nec, scelerisque id diam. Orci varius natoque penatibus et magnis dis parturient mauris.
0 commit comments