solid-meta icon indicating copy to clipboard operation
solid-meta copied to clipboard

Title tag not changing

Open awfulminded opened this issue 3 years ago • 10 comments

Maybe I don’t understand something, but I can’t change the title tag at all. I even copied the 1in1 code from the repository + created an empty project, anyway, the title and other tags do not changeю javscript not throwing any errors. Maybe it has something to do with solid-router because they have at least one common <Link> tag, but I could be wrong. Doesn't work without <Router> either.

import type { Component } from 'solid-js';
import { Meta, MetaProvider, Title } from '@solidjs/meta';

const App: Component = () => (
  <MetaProvider>
    <div class="Home">
      <Title>Title of page</Title>
      <Meta name="example" content="whatever" />
      // ...
    </div>
  </MetaProvider>
);

export default App;
import { render } from 'solid-js/web';

import App from './App';
import { Router } from '@solidjs/router';

render(() => <Router><App /></Router>, document.getElementById('root') as HTMLElement);

awfulminded avatar Sep 19 '22 16:09 awfulminded

would you be able to put this in codesandbox.io or something similar so we could see what the issues are?

outbackStack avatar Oct 06 '22 10:10 outbackStack

I had similar issue while testing the lib with just a title. I removed the hard coded title from the html then it worked.

AlexNolasco avatar Oct 16 '22 16:10 AlexNolasco

I think that the hard coded title should serve as a fallback (no js required). Is there a way to make meta work without removing the title from the html?

solution-loisir avatar Nov 10 '22 16:11 solution-loisir

We never removed or commandeered the title tag if it didn't have a data-sm attribute. 0.28.0 removed the ability to have an existing title tag at all, but that should have been fixed in 0.28.2.

The solution as it was in 0.27.5 is to add an empty data-sm attribute to it.

ryansolid avatar Dec 18 '22 23:12 ryansolid

@ryansolid thank you for fast answer (for history: there was my deleted message here 3 minutes before answer)

Sorry i run on outdated solid-meta 0.28.1
Problem solved after move to @solidjs/meta and latest version

@awfulminded can you check on latest @solidjs/meta and confirm on you side?

botanegg avatar Dec 19 '22 00:12 botanegg

@ryansolid @botanegg the issue is still reproducible on 0.28.2

boombang avatar Jan 24 '23 11:01 boombang

@boombang I just fix this by remove

tag from index.html file

e23thr avatar Jul 14 '23 08:07 e23thr

In my opinion, not only should the title in the MetaProvider be cascaded, but the title already in index.html should also be overwritten.

This is because there is already a rule that only the ‘last created one’ is applied to the titles in the MetaProvider.

extracold1209 avatar Oct 01 '23 06:10 extracold1209

Have the same issue. Removing tags from html file is not an option, I am using SPA and I would lose link previews while sharing the link. The problem solved by adding empty data-sm attribute to existing tags.

EricRovell avatar Aug 04 '24 11:08 EricRovell