When I was first introduced to GitHub, I had no idea what it was or what it could do. Between you and me, I created the account because I was told every developer should have one where they push their code.
For the longest time as a beginner I did nothing with my account. But then, becuase of my passion in tech, I started following other developers and checking out their work on GitHub. And I noticed something they had in common: they all had cool projects and contributed to open source, but their projects also had detailed README files.
So my interest in what a README was grew, and I decided to try and add one in my projects, too. I won't lie – I did it in a hurry without any knowledge of how it should be done. And honestly it wasn't great at all. Check it out HERE.
And that was how it stayed for a period of time. But with practice and continuous learning I was able to change to some better documentation like THIS, which improved engagement with the project and helped other devs get involved.
It is also important to note that a good README will help you stand out among the large crowd of developers who put their work on GitHub.
In this article, we'll learn more about what a README file is and how to write one. First let's understand what we mean by a README file.
What is a README File?
In simple words, we can describe a README file as a guide that gives users a detailed description of a project you have worked on.
It can also be described as documentation with guidelines on how to use a project. Usually it will have instructions on how to install and run the project.
It is essential for you as a developer to know how to document your project by writing a README because:
- It is the first file a person will see when they encounter your project, so it should be fairly brief but detailed.
- It will make your project standout from a bunch of others. Also be sure your project is good too.
- It will help you focus on what your project needs to deliver and how.
- It will improve your writing skills, just as Friedrich Nietzsche said:
A good writer possesses not only his own spirit but also the spirit of his friends.
While working on a project, keep in mind that you will need other developers to understand your code and what it does. So accompanying it with an extra guide will be really helpful.
For instance, my earlier shared example of my first project does not have a good README. And even though the project was amazing, it would've been hard for a beginner to understand exactly what was expected when they cloned my repo. Who knows maybe it could've even been a coded virus.
With a project like this on GitHub, no matter how amazing it is, other devs won't be eager to work on it and try to figure it out without a good README.
Now, have a look at this project. Here, you are able to understand what the project does, what it entails, and how to get started if you need to use or want to contribute to the project.
You see, that's how powerful a well written README is and how it can change you project.
So, let's get started on how to write one for you too.
How to Write a Good README – a Step by Step Guide
A very important thing to note is that there's not one right way to structure a good README. But there is one very wrong way, and that is to not include a README at all.
From research and studying various README files, for sure there are some best practices that I have found. And that's what I will be sharing. As I usually tell my self:
Every day is a learning day.
So as you progress and advance in your career, you will develop your own ideas about what makes a good README and how to improve on it. Perhaps you'll even come up with your own unique guide.
Before we get started, it is also important to note that when you're writing your project's README, it should be able to answer the what, why, and the how of the project.
Here are some guide questions that will help you out:
- What was your motivation?
- Why did you build this project?
- What problem does it solve?
- What did you learn?
- What makes your project stand out?
If your project has a lot of features, consider adding a "Features" section and listing them here.
What to Include in your README
1. Project's Title
This is the name of the project. It describes the whole project in one sentence, and helps people understand what the main goal and aim of the project is.
2. Project Description
This is an important component of your project that many new developers often overlook.
Your description is an extremely important aspect of your project. A well-crafted description allows you to show off your work to other developers as well as potential employers.
The quality of a README description often differentiates a good project from a bad project. A good one takes advantage of the opportunity to explain and showcase:
- What your application does,
- Why you used the technologies you used,
- Some of the challenges you faced and features you hope to implement in the future.
3. Table of Contents (Optional)
If your README is very long, you might want to add a table of contents to make it easy for users to navigate to different sections easily. It will make it easier for readers to move around the project with ease.
4. How to Install and Run the Project
If you are working on a project that a user needs to install or run locally in a machine like a "POS", you should include the steps required to install your project and also the required dependencies if any.
Provide a step-by-step description of how to get the development environment set and running.
5. How to Use the Project
Provide instructions and examples so users/contributors can use the project. This will make it easy for them in case they encounter a problem – they will always have a place to reference what is expected.
You can also make use of visual aids by including materials like screenshots to show examples of the running project and also the structure and design principles used in your project.
Also if your project will require authentication like passwords or usernames, this is a good section to include the credentials.
6. Include Credits
If you worked on the project as a team or an organization, list your collaborators/team members. You should also include links to their GitHub profiles and social media too.
Also, if you followed tutorials or referenced a certain material that might help the user to build that particular project, include links to those here as well.
This is just a way to show your appreciation and also to help others get a first hand copy of the project.
7. Add a License
For most README files, this is usually considered the last part. It lets other developers know what they can and cannot do with your project.
We have different types of licenses depending on the kind of project you are working on. Depending on the one you will choose it will determine the contributions your project gets.
The most common one is the GPL License which allows other to make modification to your code and use it for commercial purposes. If you need help choosing a license, use check out this link: https://choosealicense.com/
Up to this point what we have covered are the minimum requirements for a good README. But you might also want to consider adding the following sections to make it more eye catching and interactive.
Additional README Sections
Badges aren't necessary, but using them is a simple way of letting other developers know that you know what you're doing.
Having this section can also be helpful to help link to important tools and also show some simple stats about your project like the number of forks, contributors, open issues etc...
Below is a screenshot from one of my projects that shows how you can make use of badges:
The good thing about this section is that it automatically updates it self.
Don't know where to get them from? Check out the badges hosted by shields.io. They have a ton of badges to help you get started. You may not understand what they all represent now, but you will in time.
9. How to Contribute to the Project
This mostly will be useful if you are developing an open-source project that you will need other developers to contribute to. You will want to add guidelines to let them know how they can contribute to your project.
Also it is important to make sure that the licence you choose for an open-source projects is correct to avoid future conflicts. And adding contribution guidelines will play a big role.
10. Include Tests
Go the extra mile and write tests for your application. Then provide code examples and how to run them.
This will help show that you are certain and confident that your project will work without any challenges, which will give other people confidence in it, too
Here are a few extra points to note when you're writing your README:
- Keep it up-to-date - It is a good practise to make sure your file is always up-to-date. In case there are changes make sure to update the file where necessary.
- Pick a language - We all come from different zones and we all speak different languages. But this does not mean you need to translate your code into vernacular. Writing your README in English will work since English is a globally accepted language. You might want to use a translator tool here if your target audience isn't familiar with English.
There you have it, everything you need to improve your README files, or even get you started with writing your first one.
At this point I am confident that you are in a position to add an interactive and inforamative guide to your next project or even an existing one and make your project standout.
There are many tools which you can also use to automatically generate a README for your project, but it's always a good practice to try it on your own before moving to automation. In case you want to check them out, they include:
If you have read this far I really appreciate it. If you enjoyed this article and found it helpful, please share it so you can help another developer improve their projects.
I would love to see your newly crafted README file. Be sure to share a link with me via any of the links below:
Do share your valuable opinion, I appreciate your honest feedback!
Enjoy Coding ❤