I have a non-trivial amount of text, image, audio, and video content that I'm licensing as Creative Commons Attribution 4.0 International (CC BY 4.0). I chose this license because it allows people to redistribute, use or remix the content that I produce for any purpose, as long as I am properly attributed. I hope to apply this license to a site as a whole, since it applies to the vast majority of the content.

However, mixed in with this content is software source code. Are there any special concerns that I need to be aware of, with respect to license marking?

I know that:

  • The instructions for the Apache license say to include a LICENSE file in the project and a statement in the header of each source file. There's no way to include a LICENSE file in something like a Gist or a web page, but the content header is achievable. However...
  • Including the license content or the Apache required header can be obnoxious for every code block on a CC-BY page. It's far less of a problem on a Gist page, though. There may be a way to mark a page that appropriately indicates the license of source code on the page in a good way, but I haven't found guidance.
  • Creative Commons doesn't provide guidance for marking a mixed-content page on their page for marking guidance.

Ultimately, I think this boils down to two closely related questions:

  1. How should I appropriately mark source code posted to something like a GitHub Gist, where it is only a single file, especially when the license recommends a LICENSE file?
  2. How should I appropriately mark source code when posting it on CC-BY page?

My questions are somewhat related to two other questions here on Open Source:

There are a few differences, though. What I'm asking is closest to the how-to question, but unlike Stack Overflow, I don't have a profile page to use to add a disclaimer that I'm overriding a license and applying a dual-license. I'm also interested in not dual-licensing content, but applying a specific license (CC-BY 4.0) to one type of content (non-software content) and another license (Apache, BSD, MIT, etc.) to another type of content (source code).


1 Answer 1


1. Single-file formats

There are, as you correctly note, formats in which it's not possible to include a license file - GitHub gists are the most obvious. In those cases, it's not essential - license files are actually never essential, just recommended for clarity of the license. In those cases, your best bet is to use a header in the source file, specifying copyright and license. Here's an example of just this.

2. CC BY webpages

This boils down to a pretty simple question: are you the web admin? In other words, can you change that page as you like?

If you can (i.e. it's your website or something), then there are a number of things you could do. You can:

  • add a note in the footer, like SE does: content licensed under CC BY; code snippets under the MIT license (with links to the licenses)
  • add a similar note, just before or just after the code, specifying the license
  • add a paragraph in any TOS you have, specifying copyright/license status for content and code.

Be careful of saying "content" - it's ambiguous. My example above isn't worded too well; saying content licensed under CC BY; code snippets under the MIT license could be read as my code snippets are licensed under CC BY and the MIT license. You could instead say non-code content licensed...; code licensed ... to make it clearer.

If you don't control the webpage where it's displayed, then your only option is to add a header in the code itself. Assuming that the entire code file will be displayed on the page, the copyright header will also be displayed - and hopefully, the webpage's design will make the scope that the license applies to obvious.

Alternatively, if like on SE you have control over another part of the site (i.e. a personal profile), you can add a note covering all your code contributions there. See How to license Stack Overflow contributions as permissive as possible? and Can I "Override" a licensing policy? for more information on this.

  • For single files and the Apache license, would you put the complete Apache license or some shortened version, perhaps based upon what the ASF requires in source files? The Apache license is much, much longer than either of the BSD licenses or the MIT license and it may very easily take up most of a gist. Nov 27, 2015 at 12:22
  • @ThomasOwens There can be no requirements for how to apply a license beyond a clear statement from the licensor (you) that you grant rights according to the license. Because of that, I'd just put a short summary at the top of the file along the lines of "copyright 2015 Thomas Owens; this file is licensed under the terms of the Apache license. For a full copy of the license, see <url>".
    – ArtOfCode
    Nov 27, 2015 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.