1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
---
title: How to Contribute a Page
description: Learn how to write and publish a page to this website.
icon: fas fa-info
relevant_links:
Contributing to Site: https://pythondiscord.com/pages/guides/pydis-guides/contributing/site/
Using Git: https://pythondiscord.com/pages/guides/pydis-guides/contributing/working-with-git/
toc: 4
---
Pages, which include guides, articles, and other static content, are stored in markdown files in the `site` repository on Github.
If you are interested in writing or modifying pages seen here on the site, follow the steps below.
For further assistance and help with contributing pages, send a message to the `#dev-contrib` channel in the Discord server!
## Prerequisites
Before working on a new page, you have to [setup the site project locally](https://pythondiscord.com/pages/guides/pydis-guides/contributing/site/).
It is also a good idea to familiarize yourself with the [git workflow](https://pythondiscord.com/pages/guides/pydis-guides/contributing/working-with-git/), as it is part of the contribution workflow.
Additionally, please submit your proposed page or modification to a page as an [issue in the site repository](https://github.com/python-discord/site/issues), or discuss it in the `#dev-contrib` channel in the server.
As website changes require staff approval, discussing the page content beforehand helps with accelerating the contribution process, and avoids wasted work in the event the proposed page is not accepted.
## Creating the Page
All pages are located in the `site` repo, at the path `pydis_site/apps/content/resources/`. This is the root folder, which corresponds to the URL `www.pythondiscord.com/pages/`.
For example, the file `pydis_site/apps/content/resources/hello-world.md` will result in a page available at `www.pythondiscord.com/pages/hello-world`.
#### Page Categories
Nested folders represent page categories on the website. Each folder under the root folder must include a `_info.yml` file with the following:
```yml
title: Category name
description: Category description
icon: fas fa-folder # Optional
```
All the markdown files in this folder will then be under this category.
#### Having the Category Also Be a Page
In order to make categories a page, just create a page **with the same name as the category folder** in the category's parent directory.
```plaintext
guides
├── contributing.md
├── contributing
│ ├── _info.yml
│ └── bot.md
└── _info.yml
```
In the above example, `www.pythondiscord.com/guides/` will list `Contributing` as a category entry with information from `contributing/_info.yml`.
However, `www.pythondiscord.com/guides/contributing` will render `contributing.md` rather than show the category contents.
A dropdown menu will be automatically generated in the top right corner of the page listing the children of the category page.
Therefore, `www.pythondiscord.com/guides/contributing/bot` will then render `bot.md`, with backlinks to `contributing.md`.
## Writing the Page
Files representing pages are in `.md` (Markdown) format, with all-lowercase filenames and spaces replaced with `-` characters.
Each page must include required metadata, and optionally additional metadata to modify the appearance of the page.
The metadata is written in YAML, and should be enclosed in triple dashes `---` *at the top of the markdown file*.
**Example:**
```yaml
---
title: How to Contribute a Page
description: Learn how to write and publish a page to this website.
icon: fas fa-info
relevant_links:
Contributing to Site: https://pythondiscord.com/pages/guides/pydis-guides/contributing/site/
Using Git: https://pythondiscord.com/pages/guides/pydis-guides/contributing/working-with-git/
---
Pages, which include guides, articles, and other static content,...
```
### Required Fields
- **title:** Easily-readable title for your article.
- **description:** Short, 1-2 line description of the page's content.
### Optional Fields
- **icon:** Icon for the category entry for the page. Default: `fab fa-python` <i class="fab fa-python is-black" aria-hidden="true"></i>
- **relevant_links:** A YAML dictionary containing `text:link` pairs. See the example above.
- **toc:** A number representing the smallest heading tag to show in the table of contents.
See: [Table of Contents](#table-of-contents)
## Working with dark mode
If your article includes images, you can apply a few classes for a better experience for readers using dark mode.
### Add a white background to an image
Use the `has-dark-mode-background` class to apply a white background to your image, so it can be read easily in dark mode.
```md
{: class="has-dark-mode-background" }
```
### Alternate images for each mode
If you can provide two images, suited for each of the light and dark modes specifically, you can use the `light-image` and `dark-image` classes to have the correct image be used depending on the mode.
```md
{: class="light-image" }
{: class="dark-image" }
```
This way, when the reader is in light mode, only `image_light.png` is shown, and when the reader is in dark mode, only `image_dark.png` is shown.
All images with `light-image` class are hidden in dark mode and all images with `dark-image` class are hidden in light mode.
## Extended Markdown
Apart from standard Markdown, certain additions are available:
### Abbreviations
HTML `<abbr>` tags can be used in markdown using this format:
**Markdown:**
```nohighlight
This website is HTML generated from YAML and Markdown.
*[HTML]: Hyper Text Markup Language
*[YAML]: YAML Ain't Markup Language
```
**Output:**
This website is <abbr title="Hyper Text Markup Language">HTML</abbr>
generated from <abbr title="YAML Ain't Markup Language">YAML</abbr> and Markdown.
---
### Footnotes
**Markdown:**
```nohighlight
This footnote[^1] links to the bottom[^custom_label] of the page[^3].
[^1]: Footnote labels start with a caret `^`.
[^3]: The footnote link is numbered based on the order of the labels.
[^custom label]: Footnote labels can contain any text within square brackets.
```
**Output:**
This footnote[^1] links to the bottom[^custom label] of the page[^3].
[^1]: Footnote labels start with a caret `^`.
[^3]: The footnote link is numbered based on the order of the labels.
[^custom label]: Footnote labels can contain any text within square brackets.
---
### Tables
**Markdown:**
```nohighlight
| This is header | This is another header |
| -------------- | ---------------------- |
| An item | Another item |
```
**Output:**
| This is header | This is another header |
| -------------- | ---------------------- |
| An item | Another item |
---
### Codeblock Syntax Highlighting
Syntax highlighting is provided by `highlight.js`.
To activate syntax highlighting, put the language directly after the starting backticks.
**Markdown:**
````nohighlight
```python
import os
path = os.path.join("foo", "bar")
```
````
**Output:**
```python
import os
path = os.path.join("foo", "bar")
```
---
### HTML Attributes
To add HTML attributes to certain lines/paragraphs, [see this page](https://python-markdown.github.io/extensions/attr_list/#the-list) for the format and where to put it.
This can be useful for setting the image size when adding an image using markdown (see the [Image Captions](#image-captions) section for an example), or for adding bulma styles to certain elements (like the warning notification [here](/pages/guides/pydis-guides/contributing/sir-lancebot#run-with-docker)).<br>
**This should be used sparingly, as it reduces readability and simplicity of the article.**
---
### Image Captions
To add an image caption, place a sentence with italics *right below* the image link
**Markdown:**
```nohighlight
{: width="400" }
*Summmer Code Jam 2020 banner with event information.*
```
**Output:**
{: width="400"}
*Summer Code Jam 2020 banner with event information.*
> Note: To display a regular italicized line below an image, leave an empty line between the two.
---
### Table of Contents
In order to show the table of contents on a page, simply define the `toc` key in the page metadata.
The value of the `toc` key corresponds to the smallest heading to list in the table of contents.
For example, with markdown content like this:
```markdown
# Header 1
words
### Header 3
more words
# Another Header 1
## Header 2
even more words
```
and `toc: 2` in the page metadata, only `Header 1`, `Another Header 1` and `Header 2` will be listed in the table of contents.
To use a custom label in the table of contents for a heading, set the `data-toc-label` attribute in the heading line. See [HTML Attributes](#html-attributes) for more information.
```markdown
# Header 1 {: data-toc-label="Header One" }
```
## Tips
### Nested/Unhighlighted Code Blocks
To nest code blocks, increase the number of ticks in the outer block by 1. To remove highlighting from code blocks (ie. no dark background), you can use the `nohighlight` language.
`````nohighlight
````nohighlight
```python
print("Some inner code block text.")
```
````
`````
### Images in Lists
To properly indent images in lists, keep the image on the line directly after the previous line and add `<br>` to the end of the text, like this:
```markdown
1. List item text one.<br>

2. List item text two.<br>

```
### Keeping Text In The Same Paragraph
You can also use `<br>` to break lines while keeping them in the same paragraph (avoiding the vertical spacing added between paragraphs).
```nohighlight
##### Same line, same paragraph
Line A
Line B
##### Different line, different paragraph
Line A
Line B
##### Different line, same paragraph
Line A<br>
Line B
```
|