-
Notifications
You must be signed in to change notification settings - Fork 519
Angular 2.4.5 template nested html/head/body duplicates #662
Comments
That doesn't happen when I try it (with the current template and Angular 2.4.7). I get a structure like the following:
There's no nested If you can provide repro instructions for getting the nested |
I can confirm this |
Ah yes, I see what you mean. Currently this is a limitation of Angular's server-side rendering (it only understands the idea of returning a complete HTML page, not a document fragment). It's also a regression - they used to handle this better until recently. If avoiding the oddly-shaped document matters to you (and I agree it should) then please tell the Angular Universal people that you want it to support returning document fragments. I'd suggest posting to angular/angular#13822 |
@SteveSandersonMS It is kind of big deal. SEO is primary use case for Universal and we are not sure how Google would treat html like this. |
@hheexx I haven't yet heard the Angular team confirm for sure whether they are going to put back the support for returning document fragments in Angular 4. Again, if this is important to you (and I know it is to many people), then please lobby the Angular folks about it directly. |
Here is hacky code that fixes this: Also in index.cshtml I advice changing app to div because we already have app tag returned from Universal.
|
:) very interesting hack. But hey, it works. :) b.t.w. Couldn't one use @SteveSandersonMS sample code here #607 to prevent any markup from being written out from the C# side of things, then move all the js/css includes into the primary app.component.html and use only the output from Angular Universal? |
The goal is to have code setup like in #607 (since otherwise we don't get to set any of the SEO must-have's like Title / Meta tags). I'm working on getting all of that going right now, hopefully have it up and running so we can test out a few scenarios. |
So far I got them successfully integrated and server-rendering 😸 |
In addition to @hheexx answer, here is the hacky code for angular 5 in asp.net core, in resolve({
html: (() => {
let apphtml = state.renderToString();
apphtml = apphtml.replace('<html><head><style>', '<style>').replace('</head><body><app', '<app').replace('</app></body></html>', '</app>');
return apphtml;
})()}); and don't use |
I'm not sure if it's an issue, but when I look at static source of the page that gets prerendered on server I see structure like this
Which seems odd. Could it be bug?
The text was updated successfully, but these errors were encountered: