(written from a Production point of view)
Canon is a sanctioned or accepted group or body of related works. The Star Trek canon is generally defined as all released television series and feature films. The various "official" references (such as the Star Trek Encyclopedia or the Star Trek Chronology) may be used as a guide to canon information, but are not canon in and of themselves.
The definition of Star Trek canon may vary for different fans, and therefore for a reference source like Memory Alpha, the question may become especially difficult. The term fanon is used to refer to "fan canon", of which the term is a portmanteau. It applies to certain "facts" that may have been accepted as a truth by a large number of fans, and thus either replaces an established canonical fact in the minds of those fans, becoming retroactive continuity, or fills a plot-hole.
The history of defining canon Edit
In 1988, Paramount Pictures removed Star Trek: The Animated Series (aired 1973–1974) from canon. However, the definition of Star Trek canon as encompassing all released TV series and films has been generally accepted since TAS was first released on DVD; the studio officially changed its removal of TAS from canon by listing the animated series as a part of established canon in its database at StarTrek.com. 
'Canon' in the sense that I use it is a very important tool. It only gets muddled when people try to incorporate licensed products into 'canon' – and I know a lot of the fans really like to do that. Sorry, guys – not trying to rain on your parade. There's a lot of bickering about it among fans, but in its purest sense, it's really pretty simple: Canon is Star Trek continuity as presented on TV and Movie screens. Licensed products like books and comics aren't part of that continuity, so they aren’t canon. And that's that. Part of my job in licensing is to keep track of TV and Movie continuity, so I can help direct licensees in their creation of licensed products. It gets a little tricky because it's constantly evolving, and over the years, Star Trek's various producers and scriptwriters haven't always kept track of/remembered/cared about what's come before. 
In 2012, executive producer, writer, and creative consultant Roberto Orci was asked by TrekMovie.com about canon regarding the then-upcoming Star Trek videogame as well as the tie-in comic books for which he had served as creative consultant and co-writer. 
TrekMovie.com: When I was at E3 I spoke to a VP from Paramount who said the upcoming Star Trek movie game is canon from their perspective. So will you guys just wave the canon wand over the game, comic books and upcoming comic books that you are involved with?
Roberto Orci: Well I always say that I arrived in Star Trek where the rules of what is canon had already been established.
TrekMovie.com: Yes, but some of the exceptions were that extended universe things done by creators of filmed canon were also canon. My argument also is that in previous times there was a plethora of filmed material to fill out the canon of the prime universe. So the extended universe stuff was a little bit extra on the side. [...The] difference with previous Trek is that you guys are overseeing all of this. These rules aren't written in stone from my perspective and I think a lot of fans would like to hear you say, "yes these are all the adventures of Kirk, Spock and the gang and it is all canon and all ties together into a single universe." Again, with the caveat that you reserve the right to contradict any of it in a future movie and that would trump. That's my pitch to you.
Roberto Orci: OK, based on that then with you Anthony Pascale as a witness, I hereby declare anything that we oversee to be canon.
This implies that the comics for which Roberto Orci had served as creative consultant were considered canon (such as Star Trek: Countdown) as well as the video game. However, Orci later noted: "[I] said and have said exactly what you just said [that canon is limited to on-screen material] forever, but Pascale [TrekMovie.com editor] pushed me, he won't give up! [I] have said a million times that we can't determine what is canon. [On] this day, [I] said something else. 'consistency is the hobgoblin of little minds.'",  and later disputed the canonicity of the game. 
A large body of licensed Star Trek works exists that, while approved for publication by Paramount/CBS, are not considered part of Star Trek canon. This includes most of the novels, comics, games, and older reference books such as the Star Fleet Technical Manual. It is in this regard that Memory Alpha allows the term "Apocrypha" as a heading for the appendices section to separate, truncated only, information derived from these works from both the in-universe sections as well as the valid production background information sections.
Note that, over the years, background information from non-canon works has worked its way into canon Star Trek. These for example include the first names of Hikaru Sulu and Nyota Uhura, but also James T. Kirk's middle name "Tiberius" from The Animated Series when it was still considered non-canon. Remastered Star Trek also added further examples, such as the design of the non-canon 23rd century Starbase 47 being used for Starbase 6, and the Constitution-class registries derived from Greg Jein's article "The Case of Jonathan Doe Starship" written as a fan.
There is a large body of non-canon unlicensed work produced by amateur filmmakers. On paper, CBS Corporation supports and encourages the creation of fan fiction and released a set of guidelines to avoid the licenser's objection against fan produced Star Trek films. 
The recent growth of films and episodes produced by former Star Trek cast and crew has garnered much greater attention than traditional fan fiction. Projects that fall into this group include:
- Star Trek: New Voyages
- Star Trek: Of Gods and Men
- Star Trek: Axanar
- Star Trek Continues
- Star Trek: Renegades
It is these projects, in particular, that have come under intense scrutiny from CBS with its new rules as the producers of both Axanar  and Renegades  experienced to their detriment in 2015 and 2016 respectively.
The participation of former Star Trek staff and the increasing production value sophistication of these projects notwithstanding, Memory Alpha consider these productions as fan-produced, therefore remaining outside the purview of this wiki.
See also Edit
- Memory Beta – the wiki for licensed Star Trek works, both canon and non-canon, but excluding fan fiction
- Star Trek Expanded Universe – the wiki for documenting Star Trek fan fiction
- Memory Gamma – the wiki for writing Star Trek fan fiction
- What is Canon? at Ex Astris Scientia
- Canon (fiction) at Wikipedia
- Fanon (fiction) at Wikipedia