1

How to add title and favicon in meteor 1.3, using iron router and blaze ?

Zahed
  • 73
  • 2
  • 9
  • Take a look on [iron-router-title](https://github.com/VeliovGroup/Meteor-iron-router-title) lib. This lib will let you set title per-router and reactively update it. For favicon use tag inside `` – dr.dimitru Oct 06 '16 at 09:05

4 Answers4

3

In js you can set the page title anytime with:

document.title = "Foo";

This is much more flexible than including a static title in the <head> section as you generally want the title to change on a route-by-route basis.

In i-r you can do this in an onAfterAction hook ex:

onAfterAction() {
  document.title = 'mySiteName:' + Router.current().route.getName();
}

The icon can also be set dynamically, see this question

Community
  • 1
  • 1
Michel Floyd
  • 18,793
  • 4
  • 24
  • 39
1

In the default layout template of iron router add the following lines in the starting of the html file.

<head> <link rel='icon' sizes="16x16 32x32" href='/favicon.ico' > </head>

Save the /favicon.ico in public directory in the meteor root app. Don't forget the / in /favicon.ico

Ankit
  • 1,118
  • 13
  • 21
1

For favicon, add the following code in your main.html page in the head tag

<link rel='shortcut icon' type='image/x-icon' href='favicon.ico' />

For title per page, you can add in each html template the following code

{{documentTitle 'Document Title'}}

And add the following code in a js file

//global template helper

Template.registerHelper('documentTitle', function(title){
    document.title = title;
});
Monasha
  • 711
  • 2
  • 16
  • 27
0

You can use head tag inside the client/main.html file.

This will allow you to add title and favicon icon.

<head>
  <meta charset="utf-8" />
  <title>MY Title</title>
  <link rel='shortcut icon' href='favicon.ico' type='image/x-icon'/ >
</head>
Pankaj Jatav
  • 2,158
  • 2
  • 14
  • 22