Documentation/content/getting-started/wiki.md

138 lines
4.9 KiB
Markdown
Raw Normal View History

2021-06-24 04:01:37 -07:00
---
eleventyNavigation:
key: Wiki
title: Integrated Wiki
parent: GettingStarted
order: 60
---
A [wiki](https://en.wikipedia.org/wiki/Wiki) is a collaborative space on the web. It is a common practice to use wikis to collect knowledge and share information.
2022-07-05 00:12:58 -07:00
Codeberg allows you to add a wiki to a repo for additional documentation.
2021-06-24 04:01:37 -07:00
2022-07-05 00:12:58 -07:00
The user in these examples is `knut`, the polar bear and its repository is `foobar`.
2021-06-24 04:01:37 -07:00
## Activation and Permissions
2022-07-05 00:12:58 -07:00
To enable the wiki for a repository, visit the `Settings` page and activate `Enable Repository Wiki` in the `Advanced Section`. It will default to the built-in wiki which is described here, but you can add an URI to an external site the "Wiki" tab should link to.
2021-06-24 04:01:37 -07:00
{% admonition "warning" %}
Be aware that the wiki, once enabled, is accessible for _everyone_ who has `read` access to your repository - on public repositories even unauthenticated guests can access the wiki.
The wiki is _not_ a suitable place for storing private information or secrets (like passwords).
{% endadmonition %}
2021-06-24 04:01:37 -07:00
2022-07-05 00:12:58 -07:00
To edit the wiki `write` permission to the repository is required.
2021-06-24 04:01:37 -07:00
## Wiki structure
2022-07-05 00:12:58 -07:00
The wiki is essentially a separate Git repo in your repository with a predefined name in the form of `<your-repository-name>.wiki.git`.
2021-06-24 04:01:37 -07:00
It consists of [Markdown](https://en.wikipedia.org/wiki/Markdown) files (file extension `.md`) and additional assets like images.
2022-07-05 00:12:58 -07:00
No further stylesheets are needed. The Markdown files are automatically rendered according to the selected Codeberg theme.
2021-06-24 04:01:37 -07:00
## Adding content via web
2022-07-05 00:12:58 -07:00
After you have enabled the wiki you are prompted to create the initial page `Home.md`.
2021-06-24 04:01:37 -07:00
2022-07-05 00:12:58 -07:00
The web UI in your browser is currently limited to adding, updating, and deleting pages; you can't manage assets like images this way.
2021-06-24 04:01:37 -07:00
<picture>
2021-06-24 04:01:37 -07:00
<source srcset="/assets/images/getting-started/wiki/wiki_pageview.png" type="image/png">
<img src="/assets/images/getting-started/wiki/wiki_pageview.png" alt="Wiki home page with edit buttons">
</picture>
### Adding external images via web
If you cannot [use a local Git client](#adding-external-images-via-web), linking to _external_ assets like images is still possible.
<picture>
<source srcset="/assets/images/getting-started/wiki/wiki_editview.png" type="image/png">
<img src="/assets/images/getting-started/wiki/wiki_pageview.png" alt="Web editor with an arrow pointing at the "Insert Image" button">
</picture>
Clicking on the "Insert Image" button will make the following text appear in your text editor: `![](https://)`
You can read up more on how it works [in a later section](#describing-images-in-markdown).
## Adding content using a local Git client
2022-07-05 00:12:58 -07:00
You can work with the wiki repo as you would with any other Git repo on Codeberg; see our docs about managing a Git repo [via CLI](https://docs.codeberg.org/git/clone-commit-via-cli).
2021-06-24 04:01:37 -07:00
```shell
git clone git@codeberg.org:knut/foobar.wiki.git
cd foobar.wiki
2022-07-05 00:12:58 -07:00
nano Home.md # or your editor of choice
2021-06-24 04:01:37 -07:00
git commit -am "create Home page"
```
2022-07-05 00:12:58 -07:00
Editing locally allows you to use your favorite editor (preferably with Markdown syntax check and highlighting) and manage additional assets like images.
2021-06-24 04:01:37 -07:00
### Adding images using a local Git client
2022-07-05 00:12:58 -07:00
You can add images to the root directory or a specific subfolder (like `assets` or `images`) using your local Git client.
2021-06-24 04:01:37 -07:00
A feasible workflow might look like this:
```shell
# create a subfolder for images
mkdir images
cd images
2022-07-05 00:12:58 -07:00
# copy the image into this folder
2021-06-24 04:01:37 -07:00
git add images/image.png
git commit -m "add image"
git push
```
## Attaching images in Markdown documents
2021-06-24 04:01:37 -07:00
Now, you can reference the image in Markdown, like this:
**File in repository**:
2021-06-24 04:01:37 -07:00
```markdown
![image alt text](images/image.png 'image title')
2021-06-24 04:01:37 -07:00
```
**External image**:
```markdown
![image alt text](https://example.com/image.jpg 'image title')
```
When including images from Codeberg repositories, keep in mind that _you should use the raw version of the image._
2021-06-24 04:01:37 -07:00
After saving your changes, the image should be visible.
{% admonition "info" %}
In contrast to embedding external images, images in Git are only rendered after saving the wiki or Markdown file changes.
{% endadmonition %}
## Adding a sidebar and a footer
To enhance the usability of your wiki you can add a custom sidebar and a footer that are shown on every page. The sidebar will be displayed to the right of the main content and the footer below.
2022-07-05 00:12:58 -07:00
To enable the sidebar, just add a file named `_Sidebar.md` to your wiki. For a footer the file must be named `_Footer.md`.
Both file types allow common Markdown syntax to adjust the presentation to your needs.
Very basic example for a sidebar:
```markdown
- [[Home]]
### Content
- [Page 1](Page-1)
> knuts wiki
```
{% admonition "tip" %}
These files starting with `_` are hidden, so in the web UI you need to manually browse for the files. E.g. for our user _knut_ and his _foobar_ repo:
`https://codeberg.org/knut/foobar/wiki/_Sidebar`
{% endadmonition %}