diff --git a/packages/cli/src/lib/layout-utils.js b/packages/cli/src/lib/layout-utils.js
index 08f2acc6f..530bdd557 100644
--- a/packages/cli/src/lib/layout-utils.js
+++ b/packages/cli/src/lib/layout-utils.js
@@ -218,9 +218,9 @@ async function getAppLayout(pageLayoutContents, compilation, customImports = [],
: matchingRoute.label;
}
- const mergedHtml = pageRoot && pageRoot.querySelector('html').rawAttrs !== ''
+ const mergedHtml = pageRoot && pageRoot.querySelector('html') && pageRoot.querySelector('html')?.rawAttrs !== ''
? ``
- : appRoot.querySelector('html').rawAttrs !== ''
+ : appRoot && appRoot.querySelector('html') && appRoot.querySelector('html')?.rawAttrs !== ''
? ``
: '';
diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/build.default.workspace-layouts-page-and-app-dynamic.spec.js b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/build.default.workspace-layouts-page-and-app-dynamic.spec.js
index 7b56a55bd..1b8a0cbe9 100644
--- a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/build.default.workspace-layouts-page-and-app-dynamic.spec.js
+++ b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/build.default.workspace-layouts-page-and-app-dynamic.spec.js
@@ -14,7 +14,8 @@
* User Workspace
* src/
* pages/
- * index.md
+ * about.md
+ * index.html
* layouts/
* app.js
* page.js
@@ -50,7 +51,7 @@ describe('Build Greenwood With: ', function() {
runSmokeTest(['public'], LABEL);
- describe('Custom App and Page Layout', function() {
+ describe('Custom App and page with no wrapping element', function() {
let dom;
before(async function() {
@@ -71,6 +72,53 @@ describe('Build Greenwood With: ', function() {
expect(heading[0].textContent).to.equal('App Layout');
});
+ it('should not have the expected
tag from the dynamic page layout', function() {
+ const heading = dom.window.document.querySelectorAll('h2');
+
+ expect(heading.length).to.equal(0);
+ });
+
+ it('should have the expected content from the index.md', function() {
+ const heading = dom.window.document.querySelectorAll('h3');
+ const paragraph = dom.window.document.querySelectorAll('p');
+
+ expect(heading.length).to.equal(1);
+ expect(heading[0].textContent).to.equal('Home Page');
+
+ expect(paragraph.length).to.equal(1);
+ expect(paragraph[0].textContent).to.equal('Coffey was here');
+ });
+
+ it('should have the expected