mbigras
mbigras

Reputation: 8055

Where is the documentation for how to access raw markdown for a GitHub wiki page?

I read a blog post describing how to access the raw content inside a GitHub:

This is not entirely obvious (at least it wasn’t for me), but since Github wikis are actually backed by a proper Git repo, I figured it should be possible to access the raw markdown for a page by using Github’s https://raw.github.com/ style URLs.

After some minor trial/error, it turns out to be very predictable (as many things in github):

https://raw.github.com/wiki/[user]/[project]/[page].md

I have a repo mbigras/hello-world with a wiki page mbigras/hello-world/wiki/foobar. So according to the pattern above the following should work:

https://raw.github.com/wiki/mbigras/hello-world/foobar.md

It seems like GitHub has changed its routing as shown below:

$ curl https://raw.github.com/wiki/mbigras/hello-world/foobar.md
$ curl -Is https://raw.github.com/wiki/mbigras/hello-world/foobar.md 2>&1 | head -n 2
HTTP/1.1 301 Moved Permanently
Location: https://raw.githubusercontent.com/wiki/mbigras/hello-world/foobar.md
$ curl -L https://raw.github.com/wiki/mbigras/hello-world/foobar.md
{
  "foo": "bar",
  "cat": "dog",
  "red": "hat"
}

So the new pattern seems to be:

https://raw.githubusercontent.com/wiki/[user]/[project]/[page].md

Upvotes: 3

Views: 1632

Answers (2)

Alec the Geek
Alec the Geek

Reputation: 2030

So as of Feb 2019 this works

wget https://raw.githubusercontent.com/wiki/<username>/<repo-name>/<page>.md

Upvotes: 1

shaochuancs
shaochuancs

Reputation: 16246

Does GitHub publish documentation about how to access the raw markdown source for a wiki page?

Yes, GitHub documents how to export wiki in a blog, when Wikis is released in 2010.

Each wiki is a Git repository, so you're able to push and pull them like anything else. Each wiki respects the same permissions as the source repository. Just add ".wiki" to any repository name in the URL, and you're ready to go.

In your mbigras/hello-world case, the command would be:

git clone https://github.com/mbigras/hello-world.wiki.git

Upvotes: 4

Related Questions