-
Notifications
You must be signed in to change notification settings - Fork 18
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
Tags are not replaced, but getting appended #8
Comments
We can't diff what is outside of our control. SSR does a trick where it replaces by writing an attribute to server generated meta tags. We should document this. But if you add a |
@ryansolid Thanks for sharing the hidden treasure :-) |
When setting title why not just remove any existing |
@andreas-ateles As I mentioned in original message, I need it for static hosting. For example, think about it when using Facebook debugger or Twitter cards. With it, it would also resolve the root/default page's |
It appends the head as well if you have your routes like bellow - client side. import { Routes, Route } from "solid-app-router"
import { MetaProvider, Title } from "solid-meta";
function Home() {
return (
<>
<MetaProvider>
<Title>Home Page</Title>
</MetaProvider>
<div>
<h1>Home Page</h1>
</div >
</>
);
}
function About() {
return (
<>
<MetaProvider>
<Title>About Page</Title>
</MetaProvider>
<div>
<h1>About Page</h1>
</div >
</>
);
}
export default function App() {
return (<>
<h1>My Site with Lots of Pages</h1>
<Routes>
<Route path="/" element={<Home/>} />
<Route path="/about" element={< About/>} />
</Routes>
<>)
} |
You have multiple MetaProviders. Each acts independently. Wrap the whole application in a single MetaProvider and it should work fine. See: https://codesandbox.io/s/solid-meta-reproduction-3r1qgb |
thanks @ryansolid, it's working now... |
Am I missing something? My <title data-sm>Hardcoded Title</title>
...
<title>Set by Title component</title> I'm using the latest versions of The reason I'm doing this is because I deploy my site as static files to GitHub Pages, which will then be indexed by search engines. For that reason I must have a |
Yeah I thought this might be the case. We used to do something simple and just remove all the existing tags but now we try to upgrade but if the id doesn't match it stays I imagine. We probably need a convention here. I'm going to ask @nksaraf for his opinion as well. |
See #17 for what I think is an improved design that can help mitigate these issues but also provide more flexibility. |
For client-side rendering, I worked around this behavior, which was undesirable for me due to the reasons stated above, by assigning an ID to the |
Say, for example, if
index.html
is having<title>
tag already, the newtitle
tag is getting appended.. so, browser is taking the first one (which is used in theindex.html
).. in turn looks like the module is not working.As a quick fix, I had to remove the
<title>
tag from theindex.html
. But, that's not the correct solution.. as I want somewhat SEO friendly without SSR for the static hosting.Apologies for my poor English and hope the issue is clear to the author.
The text was updated successfully, but these errors were encountered: