Title: Documents from Git
Author: nilsnolde
Published: <strong>avril 3, 2020</strong>
Last modified: octobre 9, 2021

---

Search plugins

![](https://ps.w.org/documents-from-git/assets/banner-772x250.png?rev=2274827)

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://ps.w.org/documents-from-git/assets/icon.svg?rev=2274827)

# Documents from Git

 By [nilsnolde](https://profiles.wordpress.org/nilsnolde/)

[Download](https://downloads.wordpress.org/plugin/documents-from-git.2.2.0.zip)

 * [Details](https://tah.wordpress.org/plugins/documents-from-git/#description)
 * [Reviews](https://tah.wordpress.org/plugins/documents-from-git/#reviews)
 *  [Installation](https://tah.wordpress.org/plugins/documents-from-git/#installation)
 * [Development](https://tah.wordpress.org/plugins/documents-from-git/#developers)

 [Support](https://wordpress.org/support/plugin/documents-from-git/)

## Description

Official documentation: https://github.com/gis-ops/wordpress-markdown-git

This WordPress Plugin lets you easily publish, collaborate on and version control
your [**Markdown, Jupyter notebook**] documents directly from your favorite remote
Git platform, **even if it’s self-hosted**.

The advantages are:

 * Write documents in your favorite editor and just push to your remote repository
   to update your blog instantly
 * Use the power of version control: publish different versions of the document 
   in different posts, i.e. from another branch or commit than latest `master`
 * Easy to update by your readers via pull requests, minimizing the chance of stale
   tutorials

The following document types are currently supported:

 * Markdown
 * Jupyter notebooks (**only for public repositories**)

The following platforms are currently supported:

 * Github
 * Bitbucket
 * Gitlab

### Usage

**Note**, this plugin uses Github’s wonderful [`/markdown` API](https://developer.github.com/v3/markdown/)
to render to HTML. This comes with 2 caveats:

 1. Unless authenticated, the rate limit is set at 60 requests per minute. Since v1.1.0
    the plugin is capable of statically [caching content](https://tah.wordpress.org/plugins/documents-from-git/?output_format=md#caching).
    In case that’s not dynamic enough for you, your only option currently is to not
    use any cache in which case every document will be pulled from your provider every
    time someone opens it on your site. Then it’s **strongly recommended** to create
    a Github access token and register it with the plugin. Then the rate limit will
    be set to 5000 requests per hour. See [Global attributes section](https://tah.wordpress.org/plugins/documents-from-git/?output_format=md#global-attributes)
    for details on how to do that.
 2. The Markdown content cannot exceed 400 KB, so roughly 400 000 characters incl whitespace.
    If not a monographic dissertation, this should not be an applicable limit though.

### Shortcodes

The plugin features a variety of shortcodes.

#### Publish documents

The document-specific shortcodes follow a pattern of `[git-<platform>-<action>]`,
where

 * `<platform>` can be one of
    - `github`: if you use Github as your VCS platform
    - `bitbucket`: if you use Bitbucket as your VCS platform
    - `gitlab`: if you use Gitlab as your VCS platform
 * `<action>` can be one of
    - `markdown`: Render your Markdown files hosted on your VCS platform in Github’s
      rendering style
    - `jupyter`: Render your Jupyter notebook hosted on your VCS platfrom (**only
      for public repositories**)
    - `checkout`: Renders a small badge-like box with a link to the document and
      the date of the last commit
    - `history`: Renders a `<h2>` section with the last commit dates, messages and
      authors

#### Manipulate rendering style

Additionally, there’s an enclosing shortcode `[git-add-css]` which adds a `<div 
id="git-add-css" class="<classes_attribute>"` to wrap its contents. That way you
can manipulate the style freely with additional CSS classes. Follow these steps:

 1. Add a CSS file to your theme’s root folder, which contains some classes, e.g. `
    class1`, `class2`, `class3`
 2. Enqueue the CSS file by adding `wp_enqueue_style('my-style', get_template_directory_uri().'/
    my-style.css');` to the theme’s `functions.php`
 3. Add the enclosing `git-add-css` shortcode to your post with the custom CSS classes
    in the `classes` attribute, e.g.:
 4. `[git-add-css classes="class1 class2 class3"]
     [git-gitlab-checkout url=...] [git-
    gitlab-markdown url=...] [git-gitlab-history url=...] [/git-add-css]

### Attributes

Each shortcode takes a few attributes, indicating if it’s required for public or
private repositories:

 Attribute
 Action Public repo Private repo Type Description

 `url`
 all except `git-add-css` :ballot_box_with_check: :ballot_box_with_check:
string The browser URL of the document, e.g. https://github.com/gis-ops/wordpress-
markdown-git/blob/master/README.md

 `user`
 all except `git-add-css` :negative_squared_cross_mark: :ballot_box_with_check:
string The **user name** (not email) of an authorized user

 `token`
 all except `git-add-css` :negative_squared_cross_mark: :ballot_box_with_check:
string The access token/app password for the authorized user

 `cache_ttl`
 all except `git-add-css` :negative_squared_cross_mark: :negative_squared_cross_mark:
integer The time in seconds that the plugin will cache, **only for `cache_strategy
=static`**.

 `cache_strategy`
 all except `git-add-css` :negative_squared_cross_mark: :negative_squared_cross_mark:
integer Only `static` caching is implemented so far. `dynamic` caching is on the
way!

 `limit`
 `history` :negative_squared_cross_mark: :negative_squared_cross_mark: 
integer Limits the history of commits to this number. Default 5.

 `classes`
 `git-add-css` :ballot_box_with_check: :ballot_box_with_check: string
The additional CSS classes to render the content with

#### Global attributes

Since most attributes will be the same across the entire system, this plugin offers
the possibility to set all attributes globally except for `url`:

In the menu _Plugins_ ► _Plugin Editor_, choose « Documents from Git » and enter
your preferences in the `includes/config.json`.

**Note**, setting the attributes manually in the shortcode has always precedence
over any settings in `includes/config.json`.

#### Caching

Often we need to prioritize speed when loading content and, in addition, it is very
costly to fetch, load and format the content every time we need to read the content
of the post.

This plugin soon offers 2 methods for caching, `static` and `dynamic` which can 
be set via the `cache_strategy` property.

Static caching (`cache_strategy=static`)

This is the default strategy, as it doesn’t require any user action.

The property `cache_ttl` sets how many **seconds** the content cache will keep alive.

Currently there’s no way to flush the cache manually. However, changing `cache_ttl`
or the history `limit` will create a new cache.

Dynamic caching (`cache_strategy=dynamic`)

**This is not implemented yet**. See [#20](https://github.com/gis-ops/wordpress-markdown-git/issues/20)
for details.

#### `Token` authorization

You **need to** authorize via `user` and `token` if you intend to publish from a
private repository. You **don’t need to** authorize if the repository is open.

However, keep in mind that some platforms have stricter API limits for anonymous
requests which are greatly extended if you provide your credentials. So even for
public repos it could make sense. And unless you use this plugin’s [caching capabilities](https://tah.wordpress.org/plugins/documents-from-git/?output_format=md#caching),
it’s strongly recommended to register a Github access token regardless of the VCS
hosting platform, see the [beginning of the chapter](https://tah.wordpress.org/plugins/documents-from-git/?output_format=md#usage).

How to generate the `token` depends on your platform:

 * Github: Generate a Personal Access Token following [these instructions](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line)
 * Bitbucket: Generate a App Password following [these instructions](https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html#Apppasswords-Createanapppassword)
 * Gitlab: Generate a Personal Access Token following [these instructions](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#creating-a-personal-access-token)

This plugin needs only **Read access** to your repositories. Keep that in mind when
creating an access token.

### Examples

We publish our own tutorials with this plugin: https://gis-ops.com/tutorials/.

#### Publish Markdown from Github

    ```
    [git-github-markdown url="https://github.com/gis-ops/tutorials/blob/master/qgis/QGIS_SimplePlugin.md"]
    ```

#### Publish Markdown from Github with 1 hour cache

    ```
    [git-github-markdown url="https://github.com/gis-ops/tutorials/blob/master/qgis/QGIS_SimplePlugin.md" cache_ttl="3600" cache_strategy="static"]
    ```

#### Publish Jupyter notebook from Github

    ```
    [git-github-jupyter url="https://github.com/GIScience/openrouteservice-examples/blob/master/python/ortools_pubcrawl.ipynb"]
    ```

#### Publish from a private repository

    ```
    [git-bitbucket-jupyter user=nilsnolde token=3292_2p3a_84-2af url="https://bitbucket.org/nilsnolde/test-wp-plugin/src/master/README.md"]
    ```

#### Display last commit and document URL from Bitbucket

    ```
    [git-bitbucket-checkout url="https://bitbucket.org/nilsnolde/test-wp-plugin/src/master/README.md"]
    ```

#### Display commit history from Gitlab

    ```
    git-gitlab-history limit=5 url="https://gitlab.com/nilsnolde/esy-osm-pbf/-/blob/master/README.md"]
    ```

#### Use additional CSS classes to style

The following example will put a dashed box around the whole post:

    ```
    `
    ```

[git-add-css classes= »md-dashedbox »]
 [git-github-checkout url= »https://github.
com/gis-ops/tutorials/blob/master/qgis/QGIS_SimplePlugin.md »] [git-github-markdown
url= »https://github.com/gis-ops/tutorials/blob/master/qgis/QGIS_SimplePlugin.md»][
git-github-history url= »https://github.com/gis-ops/tutorials/blob/master/qgis/QGIS_SimplePlugin.
md »] [/git-add-css] `

With the following CSS file contents enqueued to your theme:

    ```
    `css
    ```

div.md_dashedbox {
 position: relative; font-size: 0.75em; border: 3px dashed; padding:
10px; margin-bottom:15px }

div.md_dashedbox div.markdown-github {
 color:white; line-height: 20px; padding:
0px 5px; position: absolute; background-color: #345; top: -3px; left: -3px; text-
transform:none; font-size:1em; font-family: « Helvetica Neue »,Helvetica,Arial,sans-
serif; } `

## Installation

Directly from WordPress plugin repository.

Or the latest with WP Pusher:

 1. Install WP Pusher (https://wppusher.com) via ZIP and activate
 2. Install from Github via WP Pusher from gis-ops/wordpress-markdown-git
 3. Activate and add shortcode to your posts.

Or install the latest code as ZIP from https://github.com/gis-ops/wordpress-markdown-
git/archive/master.zip

## FAQ

### Does the plugin offer a UI

Yes, since v2.0.0 the plugin has a subpage in the main Settings menu.

### Does the plugin support caching?

Yes, since v1.1.0 the plugin supports static caching of all relevant information.
See the [« Caching » section](https://github.com/gis-ops/wordpress-markdown-git#caching)
for details.

### Are relative links supported?

No, relative image links (e.g. `![img](./img.png)`) cannot be processed by this 
plugin. Please see the notes in the [documentation](https://github.com/gis-ops/wordpress-markdown-git#images)
for ways to work around this limitation.

### Can I host the source file in a private repository?

Yes, you can, if you provide the plugin’s `config.json` with the necessary credentials
for your platform (see [documentation](https://github.com/gis-ops/wordpress-markdown-git#global-attributes)
for details). However, be aware that all image URLs you are referencing are openly
accessible or provide the necessary authentication means. Also see [#13](https://github.com/gis-ops/wordpress-markdown-git/issues/13#issuecomment-638965192)
and the [documentation](https://github.com/gis-ops/wordpress-markdown-git#images)
for further details.

## Reviews

![](https://secure.gravatar.com/avatar/bbbe684d9bc2f313941341005e5c13f40adaa698ef5ae937e06b04aec2246bab?
s=60&d=retro&r=g)

### 󠀁[Simple but effective](https://wordpress.org/support/topic/simple-but-effective-191/)󠁿

 [trainingcity](https://profiles.wordpress.org/trainingcity/) juillet 23, 2023

This plugin is a very robust little tool for getting markdown file content into 
any WordPress page using the simple to configure short codes. It works with the 
new GitHub « Fine-grained » personal access tokens and easily handles private repos
that are accessed with SAML SSO organization settings. It would be great if they
are able to add more content types, for example, I’d love to be able to display 
code samples from Github Python py files.

![](https://secure.gravatar.com/avatar/e27209676aa9d497ccb17236cb3f8cd7bb8ce9d830d344d4e43048a8d65bc38a?
s=60&d=retro&r=g)

### 󠀁[Very useful plugin](https://wordpress.org/support/topic/very-useful-plugin-1049/)󠁿

 [Danilo Pinotti](https://profiles.wordpress.org/danilopinotti/) septembre 22, 2020

With this plugin I can centralize my post reviews at github without further efforts

![](https://secure.gravatar.com/avatar/675ef62b449de1c99383f4b4411ec08131ce2bad9163fa4c2bb062db2270776a?
s=60&d=retro&r=g)

### 󠀁[Extremely Versatile Plugin](https://wordpress.org/support/topic/extremely-versatile-plugin-4/)󠁿

 [TimothyDalton](https://profiles.wordpress.org/timothydalton/) avril 11, 2020

I have installed this plugin to pull markdown documents from GitHub and GitLab to
my websites. It works very well.

 [ Read all 3 reviews ](https://wordpress.org/support/plugin/documents-from-git/reviews/)

## Contributors & Developers

“Documents from Git” is open source software. The following people have contributed
to this plugin.

Contributors

 *   [ nilsnolde ](https://profiles.wordpress.org/nilsnolde/)
 *   [ Danilo Pinotti ](https://profiles.wordpress.org/danilopinotti/)

“Documents from Git” has been translated into 1 locale. Thank you to [the translators](https://translate.wordpress.org/projects/wp-plugins/documents-from-git/contributors)
for their contributions.

[Translate “Documents from Git” into your language.](https://translate.wordpress.org/projects/wp-plugins/documents-from-git)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/documents-from-git/),
check out the [SVN repository](https://plugins.svn.wordpress.org/documents-from-git/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/documents-from-git/)
by [RSS](https://plugins.trac.wordpress.org/log/documents-from-git/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### v2.2.0

 * plugin didn’t authenticate correctly to Github

#### v2.1.0

 * styles were not enqueued properly which led to default markdown rendering

#### v2.0.0

 * created Settings subpage for the plugin (BREAKING CHANGE)

#### v1.1.1

 * fix Gitlab URLs for subdirectory markdown paths

#### v1.1.0

 * implement static caching

#### v1.0.2

 * Fixed rate limiting for unauthenticated `/markdown` requests
 * Fixed Jupyter implementation

#### v1.0.0

 * First version

## Meta

 *  Version **2.2.0**
 *  Last updated **4 années ago**
 *  Active installations **200+**
 *  WordPress version ** 5.0.0 or higher **
 *  Tested up to **5.8.13**
 *  PHP version ** 7.0 or higher **
 *  Languages
 * [English (US)](https://wordpress.org/plugins/documents-from-git/) and [Japanese](https://ja.wordpress.org/plugins/documents-from-git/).
 *  [Translate into your language](https://translate.wordpress.org/projects/wp-plugins/documents-from-git)
 * Tags
 * [Bitbucket](https://tah.wordpress.org/plugins/tags/bitbucket/)[Github](https://tah.wordpress.org/plugins/tags/github/)
   [markdown](https://tah.wordpress.org/plugins/tags/markdown/)[Notebook](https://tah.wordpress.org/plugins/tags/notebook/)
 *  [Advanced View](https://tah.wordpress.org/plugins/documents-from-git/advanced/)

## Ratings

 5 out of 5 stars.

 *  [  3 5-star reviews     ](https://wordpress.org/support/plugin/documents-from-git/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/documents-from-git/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/documents-from-git/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/documents-from-git/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/documents-from-git/reviews/?filter=1)

[Add my review](https://wordpress.org/support/plugin/documents-from-git/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/documents-from-git/reviews/)

## Contributors

 *   [ nilsnolde ](https://profiles.wordpress.org/nilsnolde/)
 *   [ Danilo Pinotti ](https://profiles.wordpress.org/danilopinotti/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/documents-from-git/)