Adding a git repository¶
If your documentation is related to source code, MaterialX for MkDocs provides the ability to display information to the project's repository as part of the static site, including stars and forks. Furthermore, the date of last update and creation, as well as contributors can be shown.
Configuration¶
Repository¶
In order to display a link to the repository of your project as part of your
documentation, set repo_url in mkdocs.yml to the public URL of
your repository, e.g.:
The link to the repository will be rendered next to the search bar on big screens and as part of the main navigation drawer on smaller screen sizes.
Additionally, for public repositories hosted on GitHub or GitLab, the latest release tag1, as well as the number of stars and forks, are automatically requested and rendered.
Repository name¶
0.1.0
GitHub, GitLab or Bitbucket
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
repo_name in mkdocs.yml:
Repository icon¶
While the default repository icon is a generic git icon, it can be set to
any icon bundled with the theme by referencing a valid icon path in
mkdocs.yml:
-
Enter a few keywords to find the perfect icon using our icon search and click on the shortcode to copy it to your clipboard:
Some popular choices:
- –
fontawesome/brands/git - –
fontawesome/brands/git-alt - –
fontawesome/brands/github - –
fontawesome/brands/github-alt - –
fontawesome/brands/gitlab - –
fontawesome/brands/gitkraken - –
fontawesome/brands/bitbucket - –
fontawesome/solid/trash
Code actions¶
If the repository URL points to a valid GitHub, GitLab or Bitbucket
repository, MkDocs provides a setting called edit_uri, which
resolves to the subfolder where your documentation is hosted.
If your default branch is called main, change the setting to:
After making sure that edit_uri is correctly configured, buttons for code
actions can be added. Two types of code actions are supported: edit and view
(GitHub only):
The icon of the edit and view buttons can be changed with the following lines:
-
Enter a few keywords to find the perfect icon using our icon search and click on the shortcode to copy it to your clipboard:
Markdown for AI agents¶
Now, GEO (SEO applied to AI agents) is becoming an important stake for websites discoverability. To allow AI agents (Claude Code, ChatGPT, etc.) to access pages more effectively, you can use the following configuration to let AI agents directly fetch the page Markdown source.
This provides AI with well-structured content, reduces token consumption by over 80%, and greatly cuts down irrelevant noise.
After applying this configuration, an HTML link relation of type text/markdown will be automatically generated in the page header:
Note
Related introduction: Introducing Markdown for Agents
Document dates & authors¶
You can add date and author information to your documents via the next-generation Date & Author plugin document-dates.
For more details: Date & authors
Document contributors¶
The git-committers2 plugin renders the GitHub avatars of all contributors,
linking to their GitHub profiles at the bottom of each page. As always, it can
be installed with pip:
Then, add the following lines to mkdocs.yml:
The following configuration options are supported:
enabled-
trueThis option specifies whether the plugin is enabled when building your project. If you want to switch the plugin off, e.g. for local builds, use an environment variable: repository-
This property must be set to the slug of the repository that contains your documentation. The slug must follow the pattern
<username>/<repository>: branch-
masterThis property should be set to the branch of the repository from which to retrieve the contributors. To use themainbranch:
The other configuration options of this extension are not officially supported by MaterialX for MkDocs, which is why they may yield unexpected results. Use them at your own risk.
-
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 display next to the number of stars and forks. For GitLab, although it is possible to get a list of tags sorted by update time, the equivalent API endpoint is used. So, make sure you also create a release for GitLab repositories. ↩
-
We currently recommend using a fork of the git-committers plugin, as it contains many improvements that have not yet been merged back into the original plugin. See byrnereese/mkdocs-git-committers-plugin#12 for more information. ↩
