Skip to main content

How to add an "improve this content" button to your GitHub Pages site

2 min read
: If you host your site on GitHub or GitHub Pages, an edit button (and thus encouraging collaboration around your content) is simply a matter of linking to an easily predictable URL.

At the bottom of this page (and every other page on the site), you’ll notice a subtle plea to help improve the page’s content. That edit button is no dark magic. If you host your site on GitHub or GitHub Pages, collaborative content is simply a matter of linking to an easily predictable URL.

The difference between publishing with say, WordPress, and publishing using Jekyll and GitHub Pages is more than a choice of framework or platform. When you treat content as code, when you give prose the same respect that developers have for building mission-critical software, you suddenly unlock collaborative workflows whereby content can be transparently versioned, discussed, and improved. Like any other open source project, members of the public can see each line’s history, how it came to be, and propose improvements for the author to review.

If your site’s content is hosted on GitHub (either with Jekyll/GitHub Pages or something like wordpress-github-sync), it’s easy to provide readers with a link to submit changes. You simply need to add a vanilla HTML link to the following URL (if you’re using another framework, you’ll need to build the URL yourself):

https://github.com/<!-- {{ site.github.repository_nwo }} -->/edit/<!-- {{ site.branch }} -->/<!-- {{ page.path }} -->}

Luckily, GitHub Pages has a nice helper to build that URL automatically:

[Edit this page link]

Or, if you wanted the helper to build the link as well:

Please [help improve this article].

Which would output something like:

Please <a href="http://github.com/benbalter/benbalter.github.com/edit/master/_posts/2015-09-13-github-pages-edit-button.md">help improve this article</a>.

If a user clicks the link, they’ll be prompted to login or signup for a GitHub account if they haven’t already, and will be provided with a web-based editor to edit the page’s content. From there, they simply click the big green “propose change” buttons, which will silently submit a pull request to your site on their behalf, no Git or GitHub knowledge necessary.

Give it a try by clicking the edit button below (suggested improvements to this post welcome), and I encourage you to follow these steps to add a “help improve this content” button to your own site.

Originally published September 13, 2015 View revision history
Share

More to explore

If you liked it then you should have put a URL on it

8 min read

Every decision should have its own URL — one that captures not just what was decided, but who made the call, what arguments were weighed, and why. Your content deserves a permanent home.

Jekyll: Where content is truly king

2 min read

By choosing Jekyll over a traditional CMS for government.github.com, technology became a given, freeing us to spend six months iterating on what actually mattered — the content.

Eight lessons learned hacking on GitHub Pages for six months

1 min read

Believe it or not, just over a year ago, GitHub Pages, the documentation hosting service that powers nearly three-quarters of a million sites, was little more than a 100-line shell script. Today, it's a fully independent, feature-rich OAuth application that effortlessly handles well over a quarter million requests per minute. We wanted to take a look back at what we learned from leveling up the service over a six month period.

Ben Balter

Ben Balter is the Director of Hubber Enablement within the Office of the COO at GitHub, the world's largest software development platform, ensuring all Hubbers can do their best (remote) work. Previously, he served as the Director of Technical Business Operations, and as Chief of Staff for Security, he managed the office of the Chief Security Officer, improving overall business effectiveness of the Security organization through portfolio management, strategy, planning, culture, and values. As a Staff Technical Program manager for Enterprise and Compliance, Ben managed GitHub's on-premises and SaaS enterprise offerings, and as the Senior Product Manager overseeing the platform's Trust and Safety efforts, Ben shipped more than 500 features in support of community management, privacy, compliance, content moderation, product security, platform health, and open source workflows to ensure the GitHub community and platform remained safe, secure, and welcoming for all software developers. Before joining GitHub's Product team, Ben served as GitHub's Government Evangelist, leading the efforts to encourage more than 2,000 government organizations across 75 countries to adopt open source philosophies for code, data, and policy development. More about the author →

This page is open source Help improve this article on GitHub