Help:Wiki
Create a wiki page.
Our wiki is collaboratively edited by the users. It is meant as a platform to collect information about our community, the Python programming language in general and useful information. It consists of categorized pages, loosely linked together.
Location
Directory | Description |
---|---|
content/<Language>/wiki/ | The base directory of the wiki |
Create a New Wiki Page
To create a new page, use the command npm run create -- 'wiki/<pageName>.md'
.
After that you can edit your newly created page, which is located in content/en/wiki/<pageName>.md
.
Example
Create a new page foo
:
$ npm run create -- 'wiki/foo.md'
>[email protected] create
> exec-bin node_modules/.bin/hugo/hugo new "wiki/foo.md"
Content "/home/username/path_to_repository/repository_root_directory/content/en/wiki/foo.md" created
Front Matter
Every Markdown file contains a header section, called front matter, in the YAML format to configure parts of the page or website. A wiki page needs the following variables in the front matter.Variable | Type | Description |
---|---|---|
title | str | The title of the page or ressource |
url | str | The URL the page will be reachable. |
description | str | The page description, normally for SEO |
lead | str | The page description shown after the title or in cards |
date | datetime | The datetime the page was created |
lastmod | datetime | The datetime the page was modified. Should be the same as date when the creating a new page |
draft | bool | flase shows the page, true hides the page,
as it does not exist |
weight | int | The weight, or priority of the page for page sorting |
images | list of
str | Images, which will be converted and moved to the static directory. Remember to add every image you used here |
contributors | list of
str | A list of contributors |
The Datetime Type
The date and time according to ISO 8601 . The following table shows the extended format specified in ISO 8601 we use for our website to specify, when e.g. a page was created or edited. It has three parts:
- the date
- the time, including it's designator
T
- the timezone offset
Value | Optional | Description |
---|---|---|
2021 | No | Year |
07 | No | Month |
08 | No | Day of the month |
T | No | T is a designator, which indicates the start of the time representation |
12 | No | Hour |
34 | No | Minute |
56 | No | Second |
+ or - | Yes | + for a positive or - a negative timezone
offset |
01 | Yes | Timezone offset in hours |
02 | Yes | Timezone offset in minutes |
Formatting Examples
The following example uses the values from the table to show the format. It does not use the actual UTC. If you are not using the timezone offset, you must calculate UTC yourself.
- Example with timezone offset:
2021-07-08T12:34:56+01:02
- Example without timezone offset:
2021-07-08T12:34:56
Header Example
Remember, the front matter is aYAML
structure embedded into the
Markdown file. The ---
delimiters signal Hugo that this is a front
matter in the YAML
format. Here is a generated example, how the
front matter might look like:
---
title: "MyTitle"
url: "/wiki/MyTitle"
description: "A description of the page content"
lead: "A lead to the page content"
date: 2021-10-08T14:48:42+01:00
lastmod: 2021-10-08T14:48:42+01:00
draft: false
weight: 50
images: ["avatar.svg" "foo.svg" "bar.svg"]
contributors: ["UserA" "UserB" "UserC"]# This is an example for a comment in YAML
---
Notice, the weight
in wiki pages is always 50
.
Code
Below you find the implementation of the layout.
HTML
Single Page Layout
Defined in layouts/wiki/single.html
.
{{/*<!--
Wiki Layout
===========
Contributors: Michael Sasser
Maintainer: Michael Sasser
License: MIT
Version: 1
Type: Single
LAYOUT: /layouts/wiki/single.html
DOCS: /content/<language>/wiki/Help:Layout_Wiki.md
STYLE: /assets/scss/layouts/_docs.scss
Description
-----------
The single layout page for the wiki.
Changelog
=========
Version 1
---------
Initial release
-->*/}}
{{ define "main" }}
<div class="container">
<div class="row flex-lg-nowrap gap-1">
<div class="col-12 col-lg-2 docs-sidebar {{ if ne .Site.Params.options.navbarSticky true -}}docs-sidebar-top{{- end }} d-none d-lg-block">
<nav {{ if eq .Site.Params.menu.section.collapsibleSidebar false }}id="sidebar-default" {{ end }}class="docs-links" aria-label="Main navigation">
{{ partial "sidebar/docs-menu.html" . }}
</nav>
</div>
{{ if ne .Params.toc false -}}
<nav class="docs-toc{{ if ne .Site.Params.options.navbarSticky true }} docs-toc-top{{ end }} d-none d-xl-block col-xl-2" aria-label="Secondary navigation">
{{ partial "sidebar/wiki-toc.html" . }}
</nav>
{{ end -}}
{{ with .Params.toc -}}
<main class="wiki-content docs-content col-12 col-lg-10 col-xl-8">
{{ else -}}
<main class="wiki-content docs-content col-12 col-lg-10 col-xl-8 mx-xl-auto">
{{ end -}}
<h1>
{{ .Title }}
{{ if eq .Draft true }}
<span class="badge bg-danger">Draft</span>
{{ end }}
</h1>
<p class="lead">{{ .Params.lead | safeHTML }}</p>
{{ if ne .Params.toc false -}}
<nav class="d-xl-none" aria-label="Quaternary navigation">
{{ partial "sidebar/wiki-toc.html" . }}
</nav>
{{ end -}}
{{ if ne .Params.infobox false -}}
{{ partial "main/wiki-infobox.html" . }}
{{ end -}}
{{ .Content }}
<!-- categories and contributors table START -->
<div class="container-flex">
<div class="row">
<div class="col">
<div class="blog-data-section">
<!-- Last time edited -->
<div class="page-links">
<div class="sidebar-actions">
{{- partial "main/last-modified.html" . -}}
{{- if .Site.Params.editPage -}}
{{- partial "main/edit-page.html" . -}}
{{- end -}}
</div>
</div>
<table class="blog-data-table">
<tr>
<!-- Categories table head-->
{{ if isset .Params "wiki_categories" }}
<th>
<h5><i class="fa fa-folder-open"></i> Categories</h5>
</th>
{{ end }}
<!-- Tags table head-->
{{ if isset .Params "contributors" }}
<th>
<h5><i class="fa fa-group"></i> Contributors</h5>
</th>
{{ end }}
</tr>
<tr>
<!-- Categories-->
<td>
{{ with .Params.wiki_categories }}
{{ range $index, $category := . -}}
{{ if gt $index 0 -}}
{{ if eq $index (sub (len $.Params.wiki_categories ) 1) }}
<span> and </span>
{{ else -}}
<span>, </span>
{{ end -}}
{{ end -}}<a
class="stretched-link position-relative"
href="{{ "/wiki_categories/" | relURL }}{{ . | urlize }}/"
>{{ . | title }}</a
>
{{- end }}
{{ end }}
</td>
<!-- Tags -->
<td>
{{ with .Params.contributors }}
{{ range $index, $contributor := . -}}
{{ if gt $index 0 -}}
{{ if eq $index (sub (len $.Params.contributors ) 1) }}
<span> and </span>
{{ else -}}
<span>, </span>
{{ end -}}
{{ end -}}<a
class="stretched-link position-relative"
href="{{ "/contributors/" | relURL }}{{ . | urlize }}/"
>{{ . | title }}</a
>
{{- end }}
{{ end }}
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<!-- categories and contributors table END -->
</main>
</div>
</div>
{{ end }}
List Page Layout
Defined in layouts/wiki/list.html
.
{{/*<!--
Wiki Layout
===========
Contributors: Michael Sasser
Maintainer: Michael Sasser
License: MIT
Version: 1
Type: List
LAYOUT: /layouts/wiki/list.html
DOCS: /content/<language>/wiki/Help:Layout_Wiki.md
STYLE: /assets/scss/layouts/_docs.scss
Description
-----------
The list layout page for the wiki.
Changelog
=========
Version 1
---------
Initial release
-->*/}}
{{ define "main" }}
<div class="container">
<div class="row flex-xl-nowrap gap-1">
<div class="col-md-12 col-lg-2 col-xl-2 docs-sidebar d-none d-lg-block">
<nav class="docs-links" aria-label="Main navigation">
{{ partial "sidebar/docs-menu.html" . }}
</nav>
</div>
{{ if ne .Params.toc false -}}
<nav class="docs-toc {{ if ne .Site.Params.options.navbarSticky true }} docs-toc-top{{ end }} d-none d-xl-block col-xl-2" aria-label="Secondary navigation">
{{ partial "sidebar/wiki-toc.html" . }}
</nav>
{{ end -}}
{{ with .Params.toc -}}
<main class="docs-content col-md-12 col-lg-10 col-xl-8">
{{ else -}}
<main class="docs-content col-md-12 col-lg-10 col-xl-8 mx-xl-auto">
{{ end -}}
<h1>
{{ .Title }}
{{ if eq .Draft true }}
<span class="badge bg-danger">Draft</span>
{{ end }}
</h1>
<p class="lead">{{ .Params.lead | safeHTML }}</p>
{{ if ne .Params.toc false -}}
<nav class="d-xl-none" aria-label="Quaternary navigation">
{{ partial "sidebar/wiki-toc.html" . }}
</nav>
{{ end -}}
{{ .Content }}
</main>
</div>
</div>
{{ end }}
Archetype
Defined in layouts/wiki.md
.
---
title: "{{- replaceRE "_" "\\s" (.Page.File.TranslationBaseName) }}"
url: "/wiki/{{- replaceRE "\\s" "_" (.Page.File.TranslationBaseName) }}/"
description: ""
lead: ""
date: {{ .Date }}
lastmod: {{ .Date }}
contributors: []
draft: true
images: []
weight: 50
toc: true
---
Categories | Contributors |
---|---|
Help, Contribute and Layout | Michael Sasser |