A quick Creative Commons Licence with options

As some people want to licence their content under creative commons … and I said I’d write a bit of code … Here goes …

Creative Commons recommend a notice that looks like …

© 2019. This work is licensed under a CC BY 4.0 license .

Creative Commons also say the notice is put on every webpage you want to licence - so avoid just putting this in the footer on your site with out any options … unless you want all your personal photos, blog posts, etc to be licenced for re-use.

In your front matter add the param copy with options for:

  • true (Non-commercial, by Attribution)
  • ncsa (Non-commercial, ShareAlike)
  • if you dont set this … the fallback will be your Copyright notice in your footer

Then in your single layout … (as you want to licence that specific article …)

    {{ if eq .Params.copy true}}
    <div class="copy"></div><a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img alt="Creative Commons Licence" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution-NonCommercial 4.0 International License</a>.</div>
    {{else if eq .Params.copy "ncsa"}}
    <div class="copy"><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons Licence" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.</div>
    {{ end }}

Obviously - you can expand it and add more options … I didn’t do CC0 as I wouldn’t use it myself :slight_smile:

Note - I wrapped it in a custom div class so that I can later build a test to check it is present