What is MIME type "text/x-jade"?
A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.
The MIME type text/x-jade is used for template files that generate HTML. It tells software that the file contains code written in the Pug template language (formerly known as Jade).Files with this MIME type are processed and converted into clean HTML. This conversion makes web pages easier to build and maintain.
- Main use case: Server-side templating in web applications using Node.js frameworks.
- Other uses: Compiling compact syntax into static HTML and allowing embedded JavaScript for dynamic content.
- Functionality: Enhances readability using an indentation-based syntax.
Common file types include PUG and JADE files.
More technical details can be found at Pug Documentation and on the IANA Media Types page.
Associated file extensions
Usage Examples
HTTP Header
When serving content with this MIME type, set the Content-Type header:
Content-Type: text/x-jade
HTML
In HTML, you can specify the MIME type in various elements:
<a href="file.dat" type="text/x-jade">Download file</a>
Server-side (Node.js)
Setting the Content-Type header in Node.js:
const http = require('http');
http.createServer((req, res) => {
res.setHeader('Content-Type', 'text/x-jade');
res.end('Content here');
}).listen(3000);
Associated file extensions
FAQs
Do web browsers natively support text/x-jade files?
No, web browsers like Chrome and Firefox cannot render text/x-jade files directly. These files are server-side templates that must be compiled into standard HTML (usually via Node.js) before being sent to the client.
What is the relationship between text/x-jade and Pug?
The Jade templating engine was renamed to Pug due to trademark issues. While modern projects use the .pug extension, text/x-jade remains the legacy MIME type associated with older .jade files.
How do I configure Apache to serve .jade files with the correct MIME type?
If you need to serve the raw template files (e.g., for download), add the following line to your .htaccess or httpd.conf file: AddType text/x-jade .jade. However, usually, these files are processed server-side rather than served statically.
Why does my browser show raw code instead of a webpage?
This occurs if your web server sends the text/x-jade file directly to the browser instead of compiling it first. Ensure your backend application (like Express.js) is set up to render the view using the Pug/Jade engine instead of serving the file as a static asset.
Is it secure to expose text/x-jade files publicly?
Generally, no. Template files often contain application logic or structure that should remain private. You should configure your web server (Nginx/Apache) to deny access to .jade and .pug files to prevent source code disclosure.
Is text/x-jade an official IANA standard?
No, the x- prefix indicates that text/x-jade is a non-standard or experimental type. While not officially registered with IANA, it is the de facto standard used by developers and editors to identify legacy Jade template files.
How do I add text/x-jade support to Nginx?
To ensure Nginx recognizes the file type, open your mime.types file and add the extension to the definition. It should look like this: text/x-jade jade;. Remember to reload Nginx after saving changes.
General FAQ
What is a MIME type?
A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.
MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.
How do I find the MIME type for a file?
You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.
Why are multiple MIME types listed for one extension?
Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.