File name conventions for web developers

From Knowledge Kitchen
Jump to navigation Jump to search


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 experienced Search Engine Optimization (SEO) consultants even say that using dashes (-) instead of underscores (_) in file names leads to better placement on the search engine results page (SERP). I will never condone this practice.

Other applications of these conventions

These same conventions generally apply to the following:

  • variable names
  • database names
  • database table or collection names

Except that:

  • variable names written in lowerCamelCase or UpperCamelCase can include capital letters, of course
  • you don't need to put file extensions on things that aren't files

What links here