Oyekunle Oloyede
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Introduction to YAML - Syntax and Applications YAML is a text-based human-readable language used mostly used for storing configuration information and data exchange. It is a [data serialization](https://devopedia.org/data-serialization) language similar to XML and JSON. YAML originally stood for *Yet Another Markup Language* but it was later changed to the recursive acronym *YAML Ain't Markup Language* to highlight that its usage is for data storage and transmission and not as a markup language. According to the [YAML specification](https://yaml.org/spec/history/2002-04-07.html), YAML is designed for human readability and interaction with scripting languages such as Perl and Python. In this tutorial, you will learn about YAML, its syntax, and its applications. After reading this tutorial, you will know enough to read, understand, and write YAML files. ## YAML Syntax The following are the basic rules of the YAML syntax: 1. Spaces and indentations are used to define document structure. 2. Tabs are not allowed. 3. YAML files use either `.yml` or `.yaml` file extensions. 4. YAML is case-sensitive. ### Data Types in YAML In this section, we’ll look at the YAML data types and their uses. ### Strings YAML strings can be written with a pair of single(`'`) or double(`"`) quotes or without quotes. ```yaml text: unquoted another: 'a single-quoted string' alternative: "another way to write strings in YAML" ``` Multiline strings start with `|` ```yaml description: | A man of word and not of deed ``` ### Numbers ```yaml # integer age: 16 # float salary: 200.84 # scientific notation balance: 2.89e+6 ``` ### Boolean ```yaml deleted: true posted: false ``` ### Null ```yaml blank: tilde: ~ pointer: null price: Null profit: NULL ``` ### Date and Time YAML supports ISO 8601 formatted date and time. ```yaml canonical: 2001-12-15T02:59:43.1Z iso8601: 2001-12-14t21:59:43.10-05:00 time: 2020-12-07T01:02:59:34.02Z timestamp: 2020-12-07T01:02:59:34.02 +05:30 date: 2013-11-08 ``` ### Sequences Sequences allow us to declare series of items in YAML ```yaml # list of some African countries countries: - Nigeria - Ghana - Kenya ``` ### Comments Comments in YAML start with `#` ```yaml Nigeria: # this is a comment population-in-million: 201 land-mass-per-squar-kilometre: 923,768 # anothe rcomment ``` ### Nesting Values Detailed structures can be created in YAML by nesting. ```yaml # using nesting with sequences to create a list of objects bands: - Led-Zeppelin: genre: Rock albums: - Presence - Led Zeppelin - Led Zeppelin I - Pink-Floyd: genre: Rock albums: - The Wall - The Division - The Dark Side of the Moon ``` The equivalent of this in JSON would be ```json { "bands": [ { "Led-Zeppelin": { "genre": "Rock", "albums": [ "Presence", "Led Zeppelin", "Led Zeppelin I" ] } }, { "Pink-Floyd": { "genre": "Rock", "albums": [ "The Wall", "The Division", "The Dark Side of the Moon" ] } } ] } ``` Using YAML to represent a stream of employee documents ```yaml --- # An employee record name: Lukas Adebowale job: Software Engineer languages: - Perl - Python - C# address: city: Lagos zip: 100001 bio: Hacked his way from boredom to stardom. --- # separate different documents with three dashes name: Phillip Uche job: DevOps Engineer languages: - Go - Bash - Groovy address: city: Lagos zip: 100001 bio: Nothing but IT for devs ... # mark end of the document without starting a new one ``` The equivalent representation in JSON is given below ```json [ { "name": "Lukas Adebowale", "job": "Software Engineer", "languages": [ "Perl", "Python", "C#" ], "address": { "city": "Lagos", "zip": "100001" }, "bio": "Hacked his way from boredom to stardom." }, { "name": "Phillip Uche", "job": "DevOps Engineer", "languages": [ "Go", "Bash", "Groovy" ], "address": { "city": "Lagos", "zip": "100001" }, "bio": "Nothing but IT for devs" } ] ``` ## Applications YAML's human-readability and user-friendliness have led to its widespread adoption for creating configuration files. Below are some of the popular tools that use YAML: 1. Docker 2. Kubernetes 3. Swagger 4. Travis CI 5. CircleCI 6. Ansible 7. Jenkins X 8. Spring Book ## Conclusion YAML makes it easier to create human-readable configuration files and interact with scripting languages such as Perl and Python compared to JSON or XML. The syntax YAML provides allows for the creation of simple to complex data structures while still remaining human readable. Its adoption by popular DevOps tools has made learning YAML a productive skill. Thank you for reading this article. Please leave your thoughts in the comment section below.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully