Naming files
Use lowercase file, folder, and directory names. In general, separate words in filenames with hyphens, not underscores. Use standard ASCII alphanumeric characters in file, folder, and directory names.
Consistent naming
If you’re creating and naming new files where other files have a different naming convention, see if the other files and folders can be renamed with the aforementioned guidelines. If you cannot change existing filenames, it is acceptable to use underscores or other naming conventions that are in use, to remain consistent with the existing style.
For example, if the directory already has files named as theme_1.php
, theme_2.php
, and theme_3.php
, it’s acceptable to name the new file as theme_4.php
instead of theme-4.php
.
Examples
newcache.php
, newCache.php
, new-caché.php
new-cache.php
new_cache.php
wpsettings1.php
, wpSettings1.php
, WPSettings1.php
, wp-settings1.php
, wpsettings-1.php
wp-settings-1.php
wp_settings_1.php
It’s acceptable to have some inconsistency in file and folder names if it can’t be avoided otherwise. There might be predefined design and style guidelines or undocumented guidelines that are already in use. Sometimes, file naming can also be automated by the product. In those cases, it’s okay to make exceptions for those files.
Referring to files
Referring to filenames
While referring to a file, follow these guidelines:
- Use code font.
- Use the exact name of the file, even if it doesn’t follow the file naming guidelines.
- If content from the file is included in the page, follow the code example guidelines and precede the code sample or content with an introductory statement that states the filename.
Example
styles.css
file, set the opacity
to 0.75:
File interactions
While writing about file interactions, don’t use the file types as a verb.
Examples
Referring to file types
Use the formal file type instead of the file extension while referring to file types. Many file types are expressed in uppercase, as they are acronyms or initialisms.
Examples
.css
file
.py
file
The following table lists filename extensions and the corresponding file type names to use:
Extension | File type name |
---|---|
.css |
CSS file |
.csv |
CSV file |
.dmg |
DMG file |
.exe |
executable file |
.gif |
GIF file |
.html |
HTML file |
.img |
disk image file |
.jar |
JAR file |
.java |
Java file |
.jpg , .jpeg |
JPEG file |
.js |
JavaScript file |
.json |
JSON file |
.md |
Markdown file |
.mp3 |
MP3 file |
.mp4 |
MP4 file/MPEG-4 file |
.pdf |
PDF file |
.php |
PHP file |
.png |
PNG file |
.ps |
PowerShell file |
.py |
Python file |
.rar |
RAR file |
.sh |
Bash file |
.sql |
SQL file |
.svg |
SVG file |
.tar |
tar file |
.txt |
text file |
.wav |
WAV file |
.xml |
XML file |
.yaml , .yml |
YAML file |
.zip |
zip file |