7

I want to add buttons to my markdown that, when pressed, let the viewer fork, star or watch a github repository.

I already tried adding the html to my README.md, but it does not work.

Especially

<script async defer src="https://buttons.github.io/buttons.js></script>

does not seem to work (it just displays the link)

Is there a way to use Github Buttons (https://buttons.github.io) in a markdown (.md) file?

Or are there other ways to inplement this?

finnmglas
  • 1,626
  • 4
  • 22
  • 37

2 Answers2

8

If you created an image file with the button you could incorporate it directly in markdown.

For example:

[![](https://s18955.pcdn.co/wp-content/uploads/2018/02/github.png)](https://github.com/user/repository/subscription)

To control the size of the button you may need to incorporate html borrowing from this answer Changing image size in Markdown

[<img src="https://s18955.pcdn.co/wp-content/uploads/2018/02/github.png" width="25"/>](https://github.com/user/repository/subscription)
Ari Anisfeld
  • 736
  • 8
  • 14
7

It seems impossible to use the unofficial Github Buttons in a Markdown file.

However, you can use different links to access those actions (markdown style):

  • Fork:

[fork my repository](https://github.com/user/repository/fork)

  • Watch/ Follow:

[watch this repo](https://github.com/user/repository/subscription)

  • Create Issues:

[create issue](https://github.com/user/repository/issues/new)

If somebody knows a link to star a repo, I will add that to this answer :)

  • 2
    AFAIK to star a project is needed a PUT, so it can't be done from a readme markdown: https://docs.github.com/en/rest/reference/activity#star-a-repository-for-the-authenticated-user – tuxErrante Jan 23 '21 at 12:55