Having created a new page layout, added a webpartzone and a script editor snippet by snippet manager to it. Now I'm wondering how to add snippet code to the snippet editor in page layout? Is this possible and if so where to put the code?`

<!--CS: Start Script Editor Snippet--><!--SPM:<%@Register...

We would like to create a huge amount of pages and don't want to add the snippet editor code to any single page...


To replicate the same snippet on several pages without having to re-enter the web part on each page you can simple copy the page once the snippet is entered and re-name the page copy to suit. Follow these steps: - Navigate to the Site Pages library (of the site where you have created the page with the snippet on) - Locate your page and click the ... to the right of the page name - When the dialog box opens click ... (more actions), then click Copy - Complete the dialog box info for the page copy save location and name, then click OK

Your page copy including the snippet will then be saved to the pages library f your choosing. I would recommend that if you have other web part elements that will be on this page which are also to be replicated then you create them first prior to creating the page copies.


Having just used this on SharePoint Online - I would expect the process is similar. I followed the following steps:

  • Add the script editor web part to the page
  • Click edit web part on the script editor web part
  • You should then see EDIT SNIPPET in the box - click this
  • Type or paste the code you wish into the snippet editor then click Insert

If you did not want to have to insert on each subsequent page an easy workaround would then be to copy the page in the site pages library and then use it as a starter for your next page.

  • 1
    The above process should be followed, and for entering script you can write your code between <script></script>.
    – OM-ॐ
    Jun 22 '17 at 5:02
  • @Viper: where exactly to put the <script>-tag? Just after <!--CS: Start Script Editor Snippet--> ?
    – Celophysis
    Jun 22 '17 at 11:36
  • @RMcIntosh: copying into the pages library how to set this as a page layout then?
    – Celophysis
    Jun 22 '17 at 11:38
  • @Celophysis You would not set it as a page layout exactly - you are simply duplicating the same page with the snippet and re-naming it to save another instance - See my additional answer below.
    – RMcIntosh
    Jun 22 '17 at 15:23
  • 2
    No, under placerholdermail tag in script of pagelayout
    – OM-ॐ
    Jun 23 '17 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.