Can I edit html tag in meteor?


Can I edit doctype and html tag in meteor like this?

<!doctype html>
<!-- HTML 5 -->
<html class="no-js" lang="en">
  <head> and so on...

Reason I want to do it is to integrate with other third party front-end frame works such as foundation, bootstrap, or wordpress.



Currently you can’t, the best thing to do is to run some JavaScript to set that property when the page loads.

Out of curiosity, why do you need to change the doctype?


Ok that’s make sense. Thanks sashko.

why do you need to change the doctype?
Good question. Currently I’m not facing situation that I need to change doctype but maybe when I decided to use XHTML/CSS2 type of environment. I just thinking it’s good have options as long as it’s commonly used.


well, you can

meteor add meteorhacks:inject-inital

if (Meteor.isServer) {
  Inject.rawModHtml('doSomething', function(html) {
    return html.replace(/<html>/, '<!-- HTML 5 -->\n<html class="no-js" lang="en">');


sorry for reviving this topic, but apparently it can help seo to define a lang tag? (no idea if that’s accurate)


It seems like it is also important for accessibility WCAG 2.0, Guideline 3.1.1

In case you are wondering, here is the code you need in your ./server/main.js file to modify the html tag in meteor and add the lang attribute

import { Meteor } from "meteor/meteor";
import { Inject } from "meteor/meteorhacks:inject-initial";

Meteor.startup(() => {
  // code to run on server at startup
  Inject.rawModHtml("addLanguage", function(html) {
    return html.replace(/<html>/, '<!-- HTML 5 -->\n<html lang="en">');


There’s no need to mess with regex on strings. Just use the (undocumented) addHtmlAttributeHook in the webapp package:

import { WebApp } from 'meteor/webapp';
WebApp.addHtmlAttributeHook(() => ({ lang: 'en' }));


Doesn’t seem to be working in Meteor 1.8


Looks like you’re trying this on client side, try to set it in server code?