404

According to yaml.org, the official file extension is .yaml.

Quote:

Is there an official extension for YAML files?

Please use ".yaml" when possible.

However there seems to be a disagreement on the internet on which extension to use. If you look up examples on the web, many of them use the unsanctioned .yml extension.

Searching Google returns nearly 3 times as many results for the shorter one.


enter image description here
49,100


enter image description here
15,400


So which am I supposed to use? The proper 4 letter extension suggested by the creator, or the 3 letter extension found in the wild west of the internet?

spuder
  • 14,200
  • 14
  • 77
  • 129
  • 1
    As of August, 2016, YAML.org's [specification](http://www.yaml.org/spec/1.2/spec.html) is mature, and was last updated (patched) in 2009. In practice, this staleness greatly lessens the weight of their recommended extension. (BTW, their recommended extension isn't in the specification, naturally.) – MarkDBlackwell Aug 09 '16 at 14:16
  • 5
    Maybe the public should complain [here](https://sourceforge.net/p/yaml/mailman/message/25795979/) and ask them to change the official recommendation to ".yml". Organizations (and founders) naturally can be "slow," but maybe they could be convinced to follow real-world usage (if only to evangelize the language further). – MarkDBlackwell Aug 09 '16 at 14:16
  • 1
    any status update on 2017? – rocketspacer Mar 26 '17 at 15:30
  • @MarkDBlackwell failed standardization like this isn't really fixable. If people ignored their recommendation before; they'll be even more likely to ignore it if the official recommendation changes. – Andrew Wagner Jul 13 '17 at 11:01
  • 4
    @AndrewWagner, if they change their rec to `.yml`, then people might change to `.yaml` :-) – go2null Jan 26 '18 at 21:47
  • 8
    http://yaml.org/faq.html -> Use .yaml – Wannes Jun 21 '18 at 13:38
  • 9
    I'm not sure yaml.org is much help given they still show: `© 2001-2006 YAML.org All Rights Reserved` – sean Jul 24 '18 at 10:57
  • 15
    Are you using .htm or .html now? If you still stick to .htm, then probably .yml is the right choice for you. Otherwise, you may be better off getting used to using .yaml :-) – xorcus Feb 07 '19 at 19:33

4 Answers4

254

The nature and even existence of file extensions is platform-dependent (some obscure platforms don't even have them, remember) -- in other systems they're only conventional (UNIX and its ilk), while in still others they have definite semantics and in some cases specific limits on length or character content (Windows, etc.).

Since the maintainers have asked that you use ".yaml", that's as close to an "official" ruling as you can get, but the habit of 8.3 is hard to get out of (and, appallingly, still occasionally relevant in 2013).

runderworld
  • 124
  • 1
  • 3
  • 10
Bandrami
  • 3,488
  • 1
  • 11
  • 11
  • 4
    What's worse is my installation of Notepad++ seems to get this wrong :-( – Samuel Harmer Jul 28 '16 at 07:40
  • 48
    3-letter suffix convention has been obsolete for nearly 2 decades. If anything, I'd argue that the World-Wide Web deprecated it in the 90s. It's offensive that anybody even tries to care. Enough so that I'd file a bug against any piece of software that breaks because of it. – Dave Aug 01 '16 at 17:16
  • 3
    Wikipedia's [Category:Filename_extensions](https://en.wikipedia.org/w/index.php?title=Category:Filename_extensions&oldid=641316501) page lists entries for [.a](https://en.wikipedia.org/wiki/.a), [.o](https://en.wikipedia.org/wiki/.o) and [.z](https://en.wikipedia.org/wiki/.Z). Somehow, it missed [.c and .h](https://en.wikipedia.org/w/index.php?title=C_%28programming_language%29&oldid=734449132). These single-letter extensions help us see that extensions should be as long as necessary, but no longer (to half-quote [A. Einstein](https://en.wikipedia.org/wiki/Albert_Einstein)). – MarkDBlackwell Aug 14 '16 at 21:13
  • 1
    For those interested: the recommendation to use `.yaml` came as early as [Sep 2006](https://web.archive.org/web/20060924190202/http://yaml.org/faq.html). – Anthon Jan 19 '19 at 06:25
  • 35
    I named my file `.yml` and there is nothing you can do against it. – bvdb Sep 09 '19 at 11:15
  • 18
    @Dave I will keep your valuable feedback in mind. (*saving your feedback to `DOCUME~1.HTM`.*) – bvdb Mar 23 '20 at 01:02
43

EDIT:

So which am I supposed to use? The proper 4 letter extension suggested by the creator, or the 3 letter extension found in the wild west of the internet?

This question could be:

  1. A request for advice; or

  2. A natural expression of that particular emotion which is experienced, while one is observing that some official recommendation is being disregarded—prominently, or even predominantly.

People differ in their predilection for following:

  1. Official advice; or

  2. The preponderance of practice.

Of course, I am unlikely to influence you, regarding which of these two paths you prefer to take!

In what follows (and, in the spirit of science), I merely make an hypothesis, about what (merely as a matter of fact) led the majority of people to use the 3-letter extension. And, I focus on efficient causes.

By this, I do not intend moral exhortation. As you may recall, the fact that something is, does not imply that it should be.

Whatever your personal inclination, be it to follow one path or the other, I do not object.

(End of edit.)

The suggestion, that this preference (in real life usage) was caused by a 8.3 character DOS-ish limitation, IMO is a red herring (erroneous and misleading).

As of August, 2016, the Google search counts for YML and YAML were approximately 6,000,000 and 4,100,000 (to two digits of precision). Furthermore, the "YAML" count was unfairly high because it included mention of the language by name, beyond its use as an extension.

As of July, 2018, the Google's search counts for YML and YAML were approximately 8,100,000 and 4,100,000 (again, to two digits of precision). So, in the last two years, YML has essentially doubled in popularity, but YAML has stayed the same.

Another cultural measure is websites which attempt to explain file extensions. For example, on the FilExt website (as of July, 2018), the page for YAML results in: "Ooops! The FILEXT.com database does not have any information on file extension .YAML."

Whereas, it has an entry for YML, which gives: "YAML...uses a text file and organizes it into a format which is Human-readable. 'database.yml' is a typical example when YAML is used by Ruby on Rails to connect to a database."

As of November, 2014, Wikipedia's article on extension YML still stated that ".yml" is "the file extension for the YAML file format" (emphasis added). Its YAML article lists both extensions, without expressing a preference.

The extension ".yml" is sufficiently clear, is more brief (thus easier to type and recognize), and is much more common.

Of course, both of these extensions could be viewed as abbreviations of a long, possible extension, ".yamlaintmarkuplanguage". But programmers (and users) don't want to type all of that!

Instead, we programmers (and users) want to type as little as possible, and still yet be unambiguous and clear. And we want to see what kind of file it is, as quickly as possible, without reading a longer word. Typing just how many characters accomplishes both of these goals? Isn't the answer three (3)? In other words, YML?

Wikipedia's Category:Filename_extensions page lists entries for .a, .o and .Z. Somehow, it missed .c and .h (used by the C language). These example single-letter extensions help us to see that extensions should be as long as necessary, but no longer (to half-quote Albert Einstein).

Instead, notice that, in general, few extensions start with "Y". Commonly, on the other hand, the letter X is used for a great variety of meanings including "cross," "extensible," "extreme," "variable," etc. (e.g. in XML). So starting with "Y" already conveys much information (in terms of information theory), whereas starting with "X" does not.

Linguistically speaking, therefore, the acronym "XML" has (in a way) only two informative letters ("M" and "L"). "YML", instead, has three informative letters ("M", "L" and "Y"). Indeed, the existing set of acronyms beginning with Y seems extremely small. By implication, this is why a four letter YAML file extension feels greatly overspecified.

Perhaps this is why we see in practice that the "linguistic" pressure (in natural use) to lengthen the abbreviation in question to four (4) characters is weak, and the "linguistic" pressure to shorten this abbreviation to three (3) characters is strong.

Purely as a result, probably, of these factors (and not as an official endorsement), I would note that the YAML.org website's latest news item (from November, 2011) is all about a project written in JavaScript, JS-YAML, which, itself, internally prefers to use the extension ".yml".

The above-mentioned factors may have been the main ones; nevertheless, all the factors (known or unknown) have resulted in the abbreviated, three (3) character extension becoming the one in predominant use for YAML—despite the inventors' preference.

".YML" seems to be the de facto standard. Yet the same inventors were perceptive and correct, about the world's need for a human-readable data language. And we should thank them for providing it.

MarkDBlackwell
  • 1,676
  • 17
  • 26
  • 1
    [Use file extension ".yml" for YAML](http://markdblackwell.blogspot.com/2013/07/use-file-extension-yml-for-yaml.html) lists many concrete examples, recommendations, and configuration settings defaulting to ".yml" found in the wild. – MarkDBlackwell Aug 09 '16 at 13:12
  • 1
    If you cite Wikipedia, you better read a little more :[Yaml](https://en.wikipedia.org/wiki/YAML)'s article says Filename extension : `.yaml`, `.yml` – Charles Follet Aug 14 '16 at 08:29
  • 1
    @CharlesFollet, what you quoted was in fact the basis of my statement, "Its YAML article lists both extensions, without prejudice" (now edited to "without expressing a preference"). People use both extensions; yet ".yml" predominates. – MarkDBlackwell Aug 14 '16 at 20:58
  • Why did you emphasize "the"? It's very misleading if you just skim the answer. Also, your points seem too weak to warrant a claim that the creators are not "right" imo. – confused00 Sep 07 '16 at 15:08
  • @confused00 you ask, "Why did you emphasize 'the'?" I indeed did so to highlight that Wikipedia selected the word "the" (the definite article) over "a" (the indefinite article). However—based on your reaction—I've softened my conclusion; after all, YAML's inventors mainly _were_ right. – MarkDBlackwell Sep 07 '16 at 22:56
  • 23
    Always remember that Wikipedia is a **collaborative** encyclopedia. I edited the YML disambiguation page to reflect that it is just "**a common** extension" instead of "**the** extension". – NiñoScript Mar 27 '17 at 14:19
  • Not sure if the number of google results is sublime humor. But note that YML is also the opposite of FML ("F*** My Life"), as per UrbanDictionary. Those blank google searches are not a valid source of information. You could have used "filetype:..." at least, which would show dominance of "yaml". – Sebastian Mach Oct 25 '17 at 08:54
  • Thx for the good read, except you are wrong. You should use .yaml, http://yaml.org/faq.html. There you have it. – Wannes Jun 21 '18 at 13:37
  • 2
    There has been a domain specific language [YML](https://fdik.org/yml/) (markup that generates XML) for many years, maybe even as long as YAML. Your Google search count did not count is likely to have counted YML references as well as the faulty YAML references. YAML is not overspecification, it is using the appropriate name to prevent confusion. – Anthon Apr 29 '19 at 08:48
  • @Anthon Interesting! especially [YSLT – an introduction](http://fdik.org/yml/yslt). – MarkDBlackwell Apr 29 '19 at 10:58
  • 1
    As of April 1st 2020: filetype:yaml has 231.000 results, while filetype:yml has 652.000 results. So approximately 75% of the web uses yml over yaml, and that's not a joke. – Robin93K Apr 01 '20 at 10:56
10

.yaml is apparently the official extension, because some applications fail when using .yml. On the other hand I am not familiar with any applications which use YAML code, but fail with a .yaml extension.

I just stumbled across this, as I was used to writing .yml in Ansible and Docker Compose. Out of habit I used .yml when writing Netplan files which failed silently. I finally figured out my mistake. The author of a popular Ansible Galaxy role for Netplan makes the same assumption in his code:

- name: Capturing Existing Configurations
  find:
    paths: /etc/netplan
    patterns: "*.yml,*.yaml"
  register: _netplan_configs

Yet any files with a .yml extension get ignored by Netplan in the same way as files with a .bak extension. As Netplan is very quiet, and gives no feedback whatsoever on success, even with netplan apply --debug, a config such as 01-netcfg.yml will fail silently without any meaningful feedback.

ChrisW
  • 396
  • 5
  • 10
  • Info related with Netplan issue: https://bugs.launchpad.net/netplan/+bug/1815734 and https://github.com/canonical/netplan/pull/106 – julian-alarcon Apr 20 '21 at 20:12
5

After reading a bunch of people's comments online about this, my first reaction was that this is basically one of those really unimportant debates. However, my initial interest was to find out the right format so I could be consistent with my file naming practice.

Long story short, the creator of YAML are saying .yaml, but personally I keep doing .yml. That just makes more sense to me. So I went on the journey to find affirmation and soon enough, I realise that docker uses .yml everywhere. I've been writing docker-compose.yml files all this time, while you keep seeing in kubernetes' docs kubectl apply -f *.yaml...

So, in conclusion, both formats are obviously accepted and if you are on the other end, (ie: writing systems that receive a YAML file as input) you should allow for both. That seems like another snake case versus camel case thingy...

JackyJohnson
  • 2,887
  • 2
  • 24
  • 34
  • 3
    So what makes more sense for you to use for the [YML](https://fdik.org/yml/) domain specific language (which has been around for probably as long as YAML): the `.yl`, `.ym`, or the `.ml` extension? – Anthon Apr 29 '19 at 11:21