How to write a README
Tags: codenewbie, tutorial
Published: 2021-09-15 21:45:26

What is a README?  A README is a series of instructions, information, and/or guide which usually highlight a portion if not what an entire codebase does.  A README is written in Markdown syntax which may be different then what you are accustomed to besides HTML syntax.  

So why use a README?  Well, the reason I started diving into writing READMEs and taking the time to fine tune them is simply because it makes my code accessible.  It creates a guide by which those unfamiliar with my code or tech stack can gain a quick insight into the workings of my file structure, database management/schema, etc.
  

Now, how do you write a good README?

<h1>Title, short description, and image</h1>
Well first you need a title and I would recommend titling your README based on it's coverage.  A README that you find as soon as you open up a repository should be titled the name of the repository or product.  I would recommend h1 tags for this purpose. It also makes sense to put a short description (one sentence) of the overall purpose of the product or code here.  I also recommend a picture directly under your README that is a representation of your code/product. This could also be a logo for your product!  Maybe a picture of a key feature or a gif of your product in action.  Images are written in markdown syntax with the img tag.  An important note is that markdown syntax uses inline styling to position things, color things, size things, etc.  So for an image I typically mark its source (src) maybe its linked in the files or hyperlinked where it is stored.

See an example below for one of my first title, description, and image.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dzmk235cl2g4z83r9nxh.PNG)

<h1>Table of Contents</h1>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m85opwl154bjhrcbknhl.jpg)

So you have a fancy title, a short description, and an image that gives some insight into your project/product.   I believe the next thing that sets apart other READMEs is a table of contents.  How do you create a table of contents with Markdown?  Title the Table of contents with an h2 tag then use the following format.

Asterisk followed by closed square brackets that wrap the title of the content followed by parenthesis that enclose the link to the part of the README where the content is located.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7eo0enp3xeah5qbi8h56.png)

Example:
* [section 1](https://github.com/handle/yourrepo/#contentarea)
* [section 2] (https://github.com/handle/yourrepo/#contentarea) 
* [section 3] (https://github.com/handle/yourrepo/#contentarea) 

<h1>Sections</h1>

After the table of contents, the contents naturally follow.  What the contents are depends on your project/product but things that make contents easy to read are picture examples and code snippets!

How do you write a code snippet and what is it?  Let's take a look!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3e8fuz1ctazl2bzhbvd.PNG)

Three tick marks followed by the language and inside the tick marks you can place your code block.  After that close with three more tick marks!

```Javascript
function addTwo(num){
    return num + 2;
}
```

So these are what I would consider the basics of a README.  I want to expand on this later.  I will also say that it has benefited me to look at professional products and study their READMEs.  I hope this has been helpful to you!  See you in the next post.