Skip to content

Commit 662006b

Browse files
committed
Updated documentation for social cards plugin
1 parent bb72dce commit 662006b

File tree

4 files changed

+97
-25
lines changed

4 files changed

+97
-25
lines changed

CHANGELOG

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mkdocs-material-7.2.1+insiders.2.12.0 (2021-07-25)
1+
mkdocs-material-7.2.1+insiders-2.12.0 (2021-07-25)
22

33
* Added support for social cards
44

@@ -12,11 +12,11 @@ mkdocs-material-7.2.0 (2021-07-21)
1212
* Added support for search highlighting
1313
* Added support for search sharing (i.e. deep linking)
1414

15-
mkdocs-material-7.1.11+insiders.2.11.1 (2021-07-20)
15+
mkdocs-material-7.1.11+insiders-2.11.1 (2021-07-20)
1616

1717
* Fixed order of tags index, now sorted alphabetically
1818

19-
mkdocs-material-7.1.11+insiders.2.11.0 (2021-07-18)
19+
mkdocs-material-7.1.11+insiders-2.11.0 (2021-07-18)
2020

2121
* Improved Mermaid.js intergration, now stable
2222
* Added support for sequence diagrams
@@ -28,7 +28,7 @@ mkdocs-material-7.1.11 (2021-07-18)
2828

2929
* Updated Spanish and Galician translations
3030

31-
mkdocs-material-7.1.10+insiders.2.10.0 (2021-07-10)
31+
mkdocs-material-7.1.10+insiders-2.10.0 (2021-07-10)
3232

3333
* Added support for cookie consent
3434
* Fixed #2807: Back-to-top button not hidden when using sticky tabs
@@ -53,7 +53,7 @@ mkdocs-material-7.1.7 (2021-06-06)
5353

5454
* Improved screen reader support
5555

56-
mkdocs-material-7.1.6+insiders.2.9.2 (2021-05-30)
56+
mkdocs-material-7.1.6+insiders-2.9.2 (2021-05-30)
5757

5858
* Moved tags to partial for easier customization
5959
* Added support for hiding tags on any page
@@ -65,23 +65,23 @@ mkdocs-material-7.1.6 (2021-05-30)
6565
* Fixed #2429: Version selector not touch-friendly on Android devices
6666
* Fixed #2703: Printed 'Initializing search' albeit ready on mobile
6767

68-
mkdocs-material-7.1.5+insiders.2.9.1 (2021-05-24)
68+
mkdocs-material-7.1.5+insiders-2.9.1 (2021-05-24)
6969

7070
* Added missing guard for linking of content tabs
7171

72-
mkdocs-material-7.1.5+insiders.2.9.0 (2021-05-23)
72+
mkdocs-material-7.1.5+insiders-2.9.0 (2021-05-23)
7373

7474
* Added support for linking of content tabs
7575

7676
mkdocs-material-7.1.5 (2021-05-19)
7777

7878
* Fixed #2655: Details breaking page margins on print
7979

80-
mkdocs-material-7.1.4+insiders.2.8.0 (2021-05-12)
80+
mkdocs-material-7.1.4+insiders-2.8.0 (2021-05-12)
8181

8282
* Added support for boosting pages in search
8383

84-
mkdocs-material-7.1.4+insiders.2.7.2 (2021-05-08)
84+
mkdocs-material-7.1.4+insiders-2.7.2 (2021-05-08)
8585

8686
* Fixed #2638: Warnings shown when using tags plugin without directory URLs
8787

@@ -90,11 +90,11 @@ mkdocs-material-7.1.4 (2021-05-06)
9090
* Added support for git-revision-date-localized plugin creation date
9191
* Improved footnote styles on :target and :focus
9292

93-
mkdocs-material-7.1.3+insiders.2.7.1 (2021-05-03)
93+
mkdocs-material-7.1.3+insiders-2.7.1 (2021-05-03)
9494

9595
* Fixed git-revision-date-localized plugin integration (2.7.0 regression)
9696

97-
mkdocs-material-7.1.3+insiders.2.7.0 (2021-05-01)
97+
mkdocs-material-7.1.3+insiders-2.7.0 (2021-05-01)
9898

9999
* Added support for tags (with search integration)
100100

docs/insiders/index.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ yearly billing cycle][37]. If for some reason you cannot do that, you could
291291
also create a dedicated GitHub account with a yearly billing cycle, which you
292292
only use for sponsoring (some sponsors already do that).
293293

294-
One-time payments are not eligible for Insiders.
294+
If you have any problems or further questions, don't hesitate to contact me at
295+
[email protected]. Note that one-time payments are not eligible for
296+
Insiders, but of course, very appreciated.
295297

296298
[37]: https://docs.github.com/en/github/setting-up-and-managing-billing-and-payments-on-github/changing-the-duration-of-your-billing-cycle
297299

docs/reference/meta-tags.md

+8
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,12 @@ Some further examples, including [Open Graph][1] and [Twitter Cards][11]:
169169
{% endblock %}
170170
```
171171

172+
!!! tip "Automatically generated social cards"
173+
174+
If you don't want to bother with meta tags and social cards yourself, you
175+
can might be interested in the [built-in social cards plugin][12], which
176+
generates beautiful image previews for social media automatically during
177+
the build.
178+
172179
[11]: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/abouts-cards
180+
[12]: ../setup/setting-up-social-cards.md

docs/setup/setting-up-social-cards.md

+75-13
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,29 @@ template: overrides/main.html
66

77
Social cards, also known as social previews, are images that are displayed when
88
a link to your project documentation is shared on social media. Material for
9-
MkDocs can generate beautiful social cards automatically, using the colors,
10-
fonts and logo defined in `mkdocs.yml`.
9+
MkDocs can generate beautiful social cards automatically, using the [colors][1],
10+
[fonts][2] and [logo][3][^1] defined in `mkdocs.yml`.
11+
12+
[^1]:
13+
Both types of logos, images (`theme.logo`) and icons (`theme.icon.logo`)
14+
are supported. While an image logo is used as-is, icons are filled with the
15+
color used in the header (white or black), which depends on the primary
16+
color.
17+
18+
[1]: changing-the-colors.md#primary-color
19+
[2]: changing-the-fonts.md#regular-font
20+
[3]: changing-the-logo-and-icons.md#logo
1121

1222
## Configuration
1323

1424
### Built-in social cards
1525

16-
[:octicons-file-code-24: Source][1] ·
17-
[:octicons-cpu-24: Plugin][1] ·
26+
[:octicons-file-code-24: Source][4] ·
27+
[:octicons-cpu-24: Plugin][4] ·
1828
:octicons-beaker-24: Experimental ·
19-
[:octicons-heart-fill-24:{ .mdx-heart } Insiders only][1]{ .mdx-insiders }
29+
[:octicons-heart-fill-24:{ .mdx-heart } Insiders only][4]{ .mdx-insiders }
2030

21-
The [built-in social cards plugin][1] generates a social card image for every
31+
The [built-in social cards plugin][4] generates a social card image for every
2232
page and adds the necessary meta tags, so it's displayed on social media when
2333
shared. Enable it via `mkdocs.yml`:
2434

@@ -27,16 +37,16 @@ plugins:
2737
- social
2838
```
2939
30-
For example, the page on [setting up site analytics][2] renders as:
40+
For example, the page on [setting up site analytics][5] renders as:
3141
3242
<figure markdown="1">
3343
34-
[![Social Cards][3]][3]
44+
[![Social Cards][6]][6]
3545
3646
<figcaption markdown="1">
3747
3848
Want to try it out? Copy the current URL and enter it into [Twitter's Card
39-
validator][4] to see how social cards look in action.
49+
validator][7] to see how social cards look in action.
4050
4151
</figcaption>
4252
</figure>
@@ -57,7 +67,59 @@ are available:
5767
cards_directory: assets/images/social
5868
```
5969

60-
[1]: ../insiders/index.md
61-
[2]: setting-up-site-analytics.md
62-
[3]: ../assets/screenshots/social-cards.png
63-
[4]: https://cards-dev.twitter.com/validator
70+
[4]: ../insiders/index.md
71+
[5]: setting-up-site-analytics.md
72+
[6]: ../assets/screenshots/social-cards.png
73+
[7]: https://cards-dev.twitter.com/validator
74+
75+
#### Caching
76+
77+
When enabled, the [social cards plugin][8] automatically fetches the fonts you
78+
define in `mkdocs.yml` from Google Fonts, and uses them to render the text that
79+
is displayed on the social card. The font files and generated cards are both
80+
written to the `.cache` directory, which is used in subsequent builds to detect
81+
whether the social cards need to be regenerated. You might want to:
82+
83+
1. Ignore the `.cache` directory in your project, by adding it to `.gitignore`.
84+
2. When building your site for publishing, use a build cache to save the
85+
`.cache` directory in between builds. Taking the example from the
86+
[publishing guide][9], add the following lines:
87+
88+
``` yaml hl_lines="15-18"
89+
name: ci
90+
on:
91+
push:
92+
branches:
93+
- master
94+
- main
95+
jobs:
96+
deploy:
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v2
100+
- uses: actions/setup-python@v2
101+
with:
102+
python-version: 3.x
103+
- uses: actions/cache@v2
104+
with:
105+
key: ${{ github.ref }}
106+
path: .cache
107+
- run: pip install mkdocs-material
108+
- run: mkdocs gh-deploy --force
109+
```
110+
111+
[8]: #built-in-social-cards
112+
[9]: ../publishing-your-site.md
113+
114+
## Usage
115+
116+
If you want to adjust the title or set a custom description for the social card,
117+
you can use the [Metadata][10] extension, which takes precedence over the
118+
default values.
119+
120+
- [Changing the title][11]
121+
- [Changing the description][12]
122+
123+
[10]: ../reference/meta-tags.md#metadata
124+
[11]: ../reference/meta-tags.md#setting-the-page-title
125+
[12]: ../reference/meta-tags.md#setting-the-page-description

0 commit comments

Comments
 (0)