Magento – Remove Css and js from new custom page_layout from header and body Magento 2

cssjavascriptlayoutmagento-2.1page-layouts

I have created a new Design Layout (named "blank") for select in page creation
in my theme i have these created.

design/frontend/Vendor/Theme/Magento_Theme/layouts.xml

<?xml version="1.0" encoding="UTF-8"?><page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">

<layout id="blank">
    <label translate="true">Blank</label>
</layout>

design/frontend/Vendor/Theme/Magento_Theme/page_layout/blank.xml

<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
<container name="root">
        <container name="main.content" htmlTag="main" htmlId="maincontent" htmlClass="page-main">
            <container name="columns" htmlTag="div" htmlClass="columns">
                <container name="main" label="Main Content Container" htmlTag="div" htmlClass="column main"/>
            </container>
        </container>
</container>

This make the option to appear on the admin select design when i add new page but when i check the source code i can see that everything is loaded in head ( css from other pages and js ) i want a clean layout and been able to add css via Layout XML update in admin.

enter image description here

all the selected code in the image should not be there

i am pretty new to this i would appreciate some help on what i am doing wrong.
Thank you.

Best Answer

Adding new CSS

<theme-dir>/blank/layout/default_head_blocks.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="css/newtheme.css" />
    </head>
</page>

Remove static resources (JavaScript, CSS, fonts) To remove the static resources, linked in a page , make a change similar to the following in a theme extending file app/design/frontend///Magento_Theme/layout/default_head_blocks.xml

<head>
    <!-- Remove local resources -->
    <remove src="css/styles-m.css" />
    <remove src="my-js.js"/>
    <remove src="Magento_Catalog::js/compare.js" />

<!-- Remove external resources -->
    <remove src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"/>
    <remove src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"/>
    <remove src="http://fonts.googleapis.com/css?family=Montserrat" /> 

http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-manage.html#layout_markup_css_remove

Related Topic