Adding custom components to SharePoint Page layouts so that they are visible on each page created is a common requirement for SharePoint developers. To Achieve this we will follow the below steps.
- Open SharePoint designer and create a page layout with custom zones and design as required –> save page layout
- Create a new page with the page layout created and add a content editor web part in the zone required. Now add your custom client side code into the content editor web part and test for code functionality.
- Export the content editor web part with custom code to your local.
- Upload the web part to site settings –> web part
- Open Page layout in designer and Place your cursor within the zone template of required web part zone. Now Insert the custom added web part into the zone ( save page if insert web part is disabled)AddCustomWp
- Save page. Now all pages created with the page layout will have the custom component added by default.
Even though this is a simple process it will come handy when we have to add custom content on all pages across the site along with utilization of web part properties like audience targeting etc.
Happy SharePointing !!!!!