2020-07-19 22:23:26 +02:00
|
|
|
|
---
|
|
|
|
|
template: overrides/main.html
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# Adding a git repository
|
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
If your documentation is related to source code, Material for MkDocs provides
|
|
|
|
|
the ability to display information to the project's repository as part of the
|
2020-07-26 14:46:09 +02:00
|
|
|
|
static site, including statistics like stars and forks. Furthermore, individual
|
2020-07-21 13:33:44 +02:00
|
|
|
|
documents can be linked to specific source files.
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
### Repository
|
|
|
|
|
|
|
|
|
|
[:octicons-tag-24: 0.1.0][repo_url support] ·
|
|
|
|
|
:octicons-milestone-24: Default: _none_
|
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
In order to display a link to the repository of your project as part of your
|
2021-10-10 22:32:32 +02:00
|
|
|
|
documentation, set [`repo_url`][repo_url] in `mkdocs.yml` to the public URL of
|
|
|
|
|
your repository, e.g.:
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
repo_url: https://github.com/squidfunk/mkdocs-material
|
|
|
|
|
```
|
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
The link to the repository will be rendered next to the search bar on big
|
2020-07-19 22:23:26 +02:00
|
|
|
|
screens and as part of the main navigation drawer on smaller screen sizes.
|
2021-10-10 22:32:32 +02:00
|
|
|
|
Additionally, for public repositories hosted on [GitHub] or [GitLab], the
|
|
|
|
|
number of stars and forks is automatically requested and rendered.
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
2022-04-02 15:10:50 +02:00
|
|
|
|
GitHub repositories also include the tag of the latest release.[^1]
|
|
|
|
|
|
|
|
|
|
[^1]:
|
|
|
|
|
Unfortunately, GitHub only provides an API endpoint to obtain the [latest
|
|
|
|
|
release] - not the latest tag. Thus, make sure to [create a release] (not
|
|
|
|
|
pre-release) for the latest tag you want to show up next to the number of
|
|
|
|
|
stars and forks.
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[repo_url support]: https://github.com/squidfunk/mkdocs-material/releases/tag/0.1.0
|
|
|
|
|
[repo_url]: https://www.mkdocs.org/user-guide/configuration/#repo_url
|
2022-04-02 15:10:50 +02:00
|
|
|
|
[latest release]: https://docs.github.com/en/rest/reference/releases#get-the-latest-release
|
|
|
|
|
[create a release]: https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
### Repository name
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[:octicons-tag-24: 0.1.0][repo_name support] ·
|
|
|
|
|
:octicons-milestone-24: Default: _automatically set to_ `GitHub`, `GitLab` _or_
|
|
|
|
|
`Bitbucket`
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
MkDocs will infer the source provider by examining the URL and try to set the
|
|
|
|
|
_repository name_ automatically. If you wish to customize the name, set
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[`repo_name`][repo_name] in `mkdocs.yml`:
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
repo_name: squidfunk/mkdocs-material
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[repo_name support]: https://github.com/squidfunk/mkdocs-material/releases/tag/0.1.0
|
|
|
|
|
[repo_name]: https://www.mkdocs.org/user-guide/configuration/#repo_name
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
### Repository icon
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[:octicons-tag-24: 5.0.0][icon.repo support] ·
|
|
|
|
|
:octicons-milestone-24: Default:
|
|
|
|
|
[`fontawesome/brands/git-alt`][icon.repo default]
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
While the default repository icon is a generic git icon, it can be set to
|
2022-01-16 17:27:14 +01:00
|
|
|
|
any icon bundled with the theme by referencing a valid icon path in
|
|
|
|
|
`mkdocs.yml`:
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
icon:
|
2022-01-16 17:30:25 +01:00
|
|
|
|
repo: fontawesome/brands/git-alt # (1)!
|
2020-07-21 13:33:44 +02:00
|
|
|
|
```
|
|
|
|
|
|
2022-01-16 17:27:14 +01:00
|
|
|
|
1. Enter a few keywords to find the perfect icon using our [icon search] and
|
|
|
|
|
click on the shortcode to copy it to your clipboard:
|
|
|
|
|
|
|
|
|
|
<div class="mdx-iconsearch" data-mdx-component="iconsearch">
|
|
|
|
|
<input class="md-input md-input--stretch mdx-iconsearch__input" placeholder="Search icon" data-mdx-component="iconsearch-query" value="git" />
|
|
|
|
|
<div class="mdx-iconsearch-result" data-mdx-component="iconsearch-result" data-mdx-mode="file">
|
|
|
|
|
<div class="mdx-iconsearch-result__meta"></div>
|
|
|
|
|
<ol class="mdx-iconsearch-result__list"></ol>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2020-07-21 16:01:22 +02:00
|
|
|
|
Some popular choices:
|
|
|
|
|
|
2020-11-15 22:25:11 +01:00
|
|
|
|
- :fontawesome-brands-git: – `fontawesome/brands/git`
|
|
|
|
|
- :fontawesome-brands-git-alt: – `fontawesome/brands/git-alt`
|
|
|
|
|
- :fontawesome-brands-git-square: – `fontawesome/brands/git-square`
|
|
|
|
|
- :fontawesome-brands-github: – `fontawesome/brands/github`
|
|
|
|
|
- :fontawesome-brands-github-alt: – `fontawesome/brands/github-alt`
|
|
|
|
|
- :fontawesome-brands-github-square: – `fontawesome/brands/github-square`
|
|
|
|
|
- :fontawesome-brands-gitlab: – `fontawesome/brands/gitlab`
|
|
|
|
|
- :fontawesome-brands-gitkraken: – `fontawesome/brands/gitkraken`
|
|
|
|
|
- :fontawesome-brands-bitbucket: – `fontawesome/brands/bitbucket`
|
|
|
|
|
- :fontawesome-solid-trash: – `fontawesome/solid/trash`
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[icon.repo support]: https://github.com/squidfunk/mkdocs-material/releases/tag/5.0.0
|
|
|
|
|
[icon.repo default]: https://github.com/squidfunk/mkdocs-material/blob/master/material/.icons/fontawesome/brands/git-alt.svg
|
2022-01-16 17:27:14 +01:00
|
|
|
|
[icon search]: ../reference/icons-emojis.md#search
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
### Edit button
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[:octicons-tag-24: 0.1.0][edit_uri support] ·
|
|
|
|
|
:octicons-milestone-24: Default: _automatically set_
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
If the repository URL points to a [GitHub], [GitLab] or [Bitbucket] repository,
|
|
|
|
|
an edit button is displayed at the top of each document. This behavior can be
|
|
|
|
|
changed by setting [`edit_uri`][edit_uri] in `mkdocs.yml`:
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
=== "Customize edit path"
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
edit_uri: edit/master/docs/
|
|
|
|
|
```
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
=== "Hide edit button"
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
``` yaml
|
|
|
|
|
edit_uri: ""
|
|
|
|
|
```
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[edit_uri support]: https://github.com/squidfunk/mkdocs-material/releases/tag/0.1.0
|
|
|
|
|
[edit_uri]: https://www.mkdocs.org/user-guide/configuration/#edit_uri
|
|
|
|
|
[GitHub]: https://github.com/
|
|
|
|
|
[GitLab]: https://about.gitlab.com/
|
|
|
|
|
[Bitbucket]: https://bitbucket.org/
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
### Revision date
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[:octicons-tag-24: 4.6.0][git-revision-date support] ·
|
|
|
|
|
[:octicons-cpu-24: Plugin][git-revision-date]
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
The [git-revision-date] plugin adds support for displaying the date a
|
|
|
|
|
document was last updated at the bottom of each page. It can be installed
|
2020-08-01 20:21:42 +02:00
|
|
|
|
with `pip`:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
pip install mkdocs-git-revision-date-plugin
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
Then, add the following lines to `mkdocs.yml`:
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
The following configuration options are supported:
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-10-10 12:19:14 +02:00
|
|
|
|
`enabled_if_env`{ #enabled-if-env }
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
: :octicons-milestone-24: Default: _none_ – When specified, the plugin will
|
|
|
|
|
only be invoked if the environment variable exists. This makes it easy to
|
|
|
|
|
disable extraction for cases when the repository is not available:
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date:
|
|
|
|
|
enabled_if_env: CI
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
The other configuration options of this extension are not officially supported
|
|
|
|
|
by Material for MkDocs, which is why they may yield unexpected results. Use
|
|
|
|
|
them at your own risk.
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[git-revision-date support]: https://github.com/squidfunk/mkdocs-material/releases/tag/4.6.0
|
|
|
|
|
[git-revision-date]: https://github.com/zhaoterryy/mkdocs-git-revision-date-plugin
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
### Revision date, localized
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[:octicons-tag-24: 4.6.0][git-revision-date-localized support] ·
|
|
|
|
|
[:octicons-cpu-24: Plugin][git-revision-date-localized]
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
Similarly, the [git-revision-date-localized] plugin adds support for adding
|
|
|
|
|
a localized update and creation date at the bottom of each page. It can be
|
|
|
|
|
installed with `pip`:
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
pip install mkdocs-git-revision-date-localized-plugin
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then, add the following to `mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date-localized
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
The following configuration options are supported:
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-03-13 14:30:29 +01:00
|
|
|
|
`type`{ #type }
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-05-02 11:24:34 +02:00
|
|
|
|
: :octicons-milestone-24: Default: `date` – The format of the date to be
|
|
|
|
|
displayed. Valid values are `date`, `datetime`, `iso_date`, `iso_datetime`
|
|
|
|
|
and `timeago`:
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date-localized:
|
|
|
|
|
type: date
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 12:19:14 +02:00
|
|
|
|
`fallback_to_build_date`{ #fallback-to-build-date }
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-04-22 10:56:20 +02:00
|
|
|
|
: :octicons-milestone-24: Default: `false` – Enables falling back to
|
|
|
|
|
the time when `mkdocs build` was executed. Can be used as a fallback when
|
2021-10-10 22:32:32 +02:00
|
|
|
|
the build is performed outside of a git repository:
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date-localized:
|
|
|
|
|
fallback_to_build_date: true
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 12:19:14 +02:00
|
|
|
|
`enable_creation_date`{ #enable-creation-date }
|
2021-04-19 10:31:49 +02:00
|
|
|
|
|
2021-10-11 13:38:03 +02:00
|
|
|
|
: [:octicons-tag-24: 7.1.4][enable_creation_date support] ·
|
|
|
|
|
:octicons-milestone-24: Default: `false` – Enables the display of the
|
2021-10-10 22:32:32 +02:00
|
|
|
|
creation date of the file associated with the page next to the last updated
|
|
|
|
|
date at the bottom of the page:
|
2021-04-19 10:31:49 +02:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date-localized:
|
|
|
|
|
enable_creation_date: true
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
The other configuration options of this extension are not officially supported
|
|
|
|
|
by Material for MkDocs, which is why they may yield unexpected results. Use
|
|
|
|
|
them at your own risk.
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-10-10 22:32:32 +02:00
|
|
|
|
[git-revision-date-localized support]: https://github.com/squidfunk/mkdocs-material/releases/tag/4.6.0
|
|
|
|
|
[git-revision-date-localized]: https://github.com/timvink/mkdocs-git-revision-date-localized-plugin
|
2021-10-11 13:38:03 +02:00
|
|
|
|
[enable_creation_date support]: https://github.com/squidfunk/mkdocs-material/releases/tag/7.1.4
|