File Name Conventions for Web Developers
Trained web developers should have good habits. All files you create should follow simple naming convention:
- only alphabetic characters
- no capital letters
- no spaces
- no special characters, except the underscore
_
character - always use filename extensions:
.html
for HTML markup files.css
for CSS style sheet files.js
for Javascript files.gif
for GIF image files.jpg
for JPEG image files.png
for PNG image files.php
for PHP files.py
for Python files.txt
for text files.csv
for text files with comma-separated values.zip
for compressed zip files- etc…
Principled stand on the minus sign
The current generation of highly-skilled web developers often use the -
character in filenames and some very-experienced Search Engine Optimization (SEO) consultants even pronounce that using dashes (-
) instead of underscores (_
) in file names leads to better placement on the search engine results page (SERP) leading to more visitors to websites that use them. We will never condone this practice.
Other applications of these conventions
These same conventions generally apply to the following:
- variable names
- function names
- database names
- database table or collection names
… except that:
- you don’t need to put filename extensions on things that aren’t files
- there are some programming languages and technologies that have a strict convention of using lowerCamelCase, UpperCamelCase, or other naming scheme - in those cases, follow the conventions of the technology you are using.