Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to override existing tags specified in index.html? #58

Open
jurgenwerk opened this issue May 3, 2019 · 1 comment
Open

How to override existing tags specified in index.html? #58

jurgenwerk opened this issue May 3, 2019 · 1 comment

Comments

@jurgenwerk
Copy link

I have a problem where my app index is not prerendered, but nested routes are (served via different origins).

I want to be able to have default tags in my index.html and override it using ember-cli-head when needed.

In my index.html I would like to have:

<head>
  <meta name="og:title" content="Some title">
  ...
</head

But when using ember-cli-head in some nested routes, duplicates happen:

<head>
  <meta name="og:title" content="Some title">
  ...

  <meta name="ember-cli-head-start" content="">
  <meta name="og:title" content="Some more appropriate title">
  <meta name="ember-cli-head-end" content="">

</head

I get duplicates for og:title.

So when social media bots scrape my FastBoot routes, they take the first property. But they should take the second one.

How can I get ember-cli-head to render its stuff either at the beginning of the head, or replace tags that are already present in the head in index.html?

@claronz
Copy link

claronz commented Jun 17, 2020

I don't think you can have two tags of the same name at once,
But handlebars {{#if}} tags works fine in head.hbs
So here's what I'd do in the head.hbs

{{#if model.title}}
	<title>{{model.title}}</title>
	<meta property="og:title" content="{{model.title}}" /> 
{{else}}
	<title>Your default title</title>
	<meta property="og:title" content="Your Default Title" /> 
{{/if}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants