@@ -6,19 +6,29 @@ template: overrides/main.html
66
77Social cards, also known as social previews, are images that are displayed when
88a 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
2232page and adds the necessary meta tags, so it's displayed on social media when
2333shared. 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
3848Want 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