-
Notifications
You must be signed in to change notification settings - Fork 275
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
Multi-site Plugin Support for Canonicals #1671
Comments
Thank you for reporting this @jdilday. I'd like to add a little bit of context and our reasoning behind why GraphQLSiteInfoService is the way it is right now. The main thing is we don't want to retrieve more things than we need, thus loading Sitecore and JSS app a little bit less. Retrieving all of the field values could bloat config.js. While it is a kind of a "util" file not meant to be read much, it's best to have it legible. |
I agree with your point about not wanting to pull all of the possible data in the SiteInfoService, that makes total sense. The challenge we are solving involves the multi-site scenario where we have one head app serving multiple sites. Neither the multi-site plugin nor the SiteInfoService offer a way to get the canonical URL for the head section of a page when using SSG. In our scenario, the host name can't be pulled from the route as that can't be known at compile time. We also can't set the hostname as a Vercel variable because, again, it's only one head app serving several sites with different hostnames. We solved the issue by creating a custom plugin that retrieves the 'Other Properties' field using a method similar to the SiteInfoService. We store the canonical hostname for each site in that field. We tried to extend the SiteInfoService, but that would require extending/overriding most of the types, functions, and the GraphQL query so we felt it was better create our own custom plugin. Can you please elaborate on "just getting the attributes field"? |
@jdilday "Other properties" field is actually what I meant as "attributes field" :) |
@art-alexeyenko - great to hear! Thanks for adding this to your backlog. We will continue using our custom plugin, but replace it with your updates whenever they're ready. |
@art-alexeyenko - FYI - the favicon also has the same issue as canonical when using multi-site. Using above mentioned solution. No action expected, informational post only. |
Describe the Bug
Building canonicals for a SSG head app is usually solved by adding a Vercel env variable or related with the desired host name. In cases where there is a single head app tied to multiple sites in Sitecore this approach does not work.
The multi-site plugin uses the SiteInfoSearchService to grab and store select fields from the Site items from each site in Sitecore and write them to the temp/config.js file. It is not practical to extend this service to include any additional fields from the site item without completely rewriting the service.
To Reproduce
Setting an environment variable on the head app will result in all Sitecore sites that share the same head app to use the same/wrong canonical host name.
The SiteInfoService cannot be extended to include additional fields without rewriting it.
Expected Behavior
The multi-site plugin should write site field values to the temp/config.js file that include those needed for constructing a canonical URL when using SSG.
Possible Fix
Assuming the SiteInfoService was modified to do so, include the ability to get additional fields from the Site items that include values needed to generate the correct canonical meta tags in the single app, multiple site scenario.
Provide environment information
The text was updated successfully, but these errors were encountered: