DEV Community

Cover image for How to build your first web project like a Pro
Rafsan Jany Ratul
Rafsan Jany Ratul

Posted on

How to build your first web project like a Pro

when we build our first web project, sometimes we see that every file we create stays together at the same place but it is not a good practise. When we drop a HTML,CSS,image file together in one folder then when our project grow there will be a chances of making mistake. In this article i will show you how to decorate your first website like a pro so that in future when we move to MERN or React it will be easier to handle everything.

1. Making clean folder structure
at the beginning of project, we have to setup our folders like this

my-project/
│
├── index.html
├── /assets
│   ├── /images
│   ├── /icons
│   └── /fonts
│
├── /css
│   ├── style.css
│   └── responsive.css
│
├── /js
│   ├── script.js
│   └── utils.js
│
└── /components
    ├── navbar.html
    └── footer.html
Enter fullscreen mode Exit fullscreen mode

Why it works well :

  • we can find our code easily

  • we can reuse the same component again when needed

  • deployment will be easier on github pages or another hosting platforms

2. CSS files should be separate instead of creating one file

in most cases we make mistake of writing all our code in one
style.css file.But if we do like that then when needed we have to face difficulty to find. To solve this problem we can divide files like that,

  • style.css main design

  • responsive.css mobile and tabs design

  • animation.css if we use animation
    if we organize like that then it will be easier to maintain code and files.

3. Separate Javascript Files
We can organize JS files like that,

  • script.js for DOM manipulation

  • data.js for static data or objects

  • utils.js for helper functions

If we do this our code will be modular, which will give us more flexiblity to learn React or Node.js

4. We have to reuse common component
In our project sometimes we have to reuse navbar footer
or header for better practise, we need to separate these files like navbar.html, footer.html
If we want then we can include this automated using tamplate engine.

5. Naming and code style will be same
it is important to maintain when we making a project

  • every folder and files name will be in lowercase

  • avoid space use hyphen(-) like, main-section

  • we have to indent HTML/CSS properly

  • we have to maintain same naming convention

6. Version Control using form the first day
in our first froject we should use git and github. We dont need to be expart in this time but learn the basics

git init
git add .
git commit -m "Initial commit"
git push origin main
Enter fullscreen mode Exit fullscreen mode

This helps you:

  • Backup your work
  • Track changes
  • Show your projects publicly

7. Bonus: Recommended Folder Setup for Larger Projects
When you move into React or Node.js later, you’ll see similar structures — so learning it now gives you a big head start.

project/
├── public/
├── src/
│   ├── components/
│   ├── pages/
│   ├── styles/
│   ├── scripts/
│   └── utils/
└── package.json
Enter fullscreen mode Exit fullscreen mode

so start simple but think like a pro

Conclusion
At the first time we may think that organize file structure is a extra work and boaring but after some days we will understand that it will increase our productivity more.
when a project folder we open and see every files are organized then it show that someone professional who write the code clearly and better way.

Now your Turns
How do you organize your project folders?
Do you prefer everything in one place, or a modular structure?
Share your setup in the comments — I’d love to see how others do it!

Top comments (0)