"Open GitHub Issue about this page" link

This is half a Hugo question, half a GitHub question…

I have links on my site called “Edit this page”:

{{with $File.Path }}
      <div id="top-github-link">
        <a class="github-link" href="{{ $Site.Params.editURL }}{{ replace $File.Dir "\\" "/" }}{{ $File.LogicalName }}" target="blank">
          <i class="fa fa-code-fork"></i>
          {{T "Edit-this-page"}}
        </a>
       </div>
{{ end }}

This takes my users to GitHub where they can edit my page’s source code, as intended.

My question is: how to do something similar, but to Open an Issue on GitHub referencing the current page?

A nice addition would be the possibility to add some default labels.

Do you know if GitHub allows for this? Has anyone done it from Hugo? If so, please share the code. Thanks!

I don’t know if GitHub creates issues like that, though I presume it does. If it does, it is just adding parameters. So in your template it just looks something like:

<a href="example.com/create/issue?title={{ .url }}">

Put that in your single page layouts, and it will load values from that content.

Github has an API so if you can’t do this with url params and an auth token, you could make a cgi script to pull those in, and then make the issue inside the script.

Edit - just want to add that I’d do it with the script, because you can hide the token that way. Even if you can do the auth by sticking the token in an URL param (not sure, sorry), it’s not a good idea where that’s exposed as a link. It’s inviting abuse.

Thanks for your input!

I think I have the syntax I need, it seems to work:

https://github.com/Accendere/SuiteDocs/issues/new?title=MyTitle&body=Some%20Text&labels=Bug

This does not use any authentication, which is what I want - I just drop people on the page, and they take it from there. If they have a Github user, it works, if not, they are asked to create it.

Now I just need to make this work with Hugo and with my specific Page Titles. I’m just starting with Hugo, so this isn’t simple for me, but anyway now I’m certain that when I can invest the time in this, I will be able to pull it off…

Multiple labels:

&labels=foo,bar

Other allowed variables:

&assignee=

and

&milestone=