سؤال

I want to be able to use Meteor template helpers to dynamically specify the content of a <meta> tag. It seems like there is no way to do this.

If I put the <meta> tag in a free-floating <head> element (i.e. not in a template), both will be included correctly in the HTML, but I can't use template helpers.

If I move the <meta> to a template, and try to render the template within a free-floating <head> element, it complains.

And if I move the whole <head> element into a template, now I have a <head> block nested within the <body>, which is ugly, and I suspect invalid HTML (though Chrome seems to handle it gracefully).

Is there a solution?

هل كانت مفيدة؟

المحلول

It is not currently possible to this without post load insertion due to they way Meteor parses templates

نصائح أخرى

Just to bump an old thread as this is now possible on initial page load, you can try out this package https://atmospherejs.com/pip87/initial-iron-meta not tested it outside my environment much but seems to work well. Was hacked apart from kadiras fast render to handle og tags etc getting inserted onto initial page load only so it, doesn't handle switching between pages at the moment only renders for the initial page load which was what I wanted for seo bots. Also needs iron router to work.

Data gets injected from the server side call to the route in the same way the iron routers fast-render package works

I wouldn't recommend this on its own as some bots like Google will penalise if the content isn't available so having ssr or spiderable for seo bots is defiantly advisable to offer a fully rendered page to the bot, this package was meant as more of a fallback for non ajax supporting bots and those only interested in head tags

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top