2

I have a project with multiple page layouts. Some of these page layouts need a very simple image carrousel.

I would like to create a single html file and reference it somehow in several page layouts.

The first thing that came to my mind was to do it as an include, but I just couldn't get it to work because I don't know the route to the file. I was trying to do it like this:

<!--#include virtual="/includes/carrousel.aspx"-->

What would be the simplest way to achieve this? Is an include the best way?

0

Edit the page layouts in SharePoint Designer and add any html or javascript code there.

Store any files (css, scripts, jQuery libraries) required in the Site Collection's Style Library or a sub folder and reference these files in the page layout. Any user of a site collection has read access to published files in the Style Library.

You can add a Content Editor Webpart and use the content link property to link to an html or js file in your Style Library.

Publish the page layout and all the files in the Style Library to make it work for all users.

  • Thanks for your answer. But how exactly would you reference the html file? I've been trying and researching and can't find any info on how to do what I'm looking for. Is it via asp include? Thanks! – GuayoMena Jan 14 '16 at 3:45
  • Html would need to be injected via a Content Editor Web Part. I've adjusted my answer. – teylyn Jan 14 '16 at 5:34
  • Thanks for you're answer, but what I'm trying to do is insert a html snippet in several page layouts. A content Editor Webpart doesn't work for that because you would have to add the html code in every single page, and if you want to edit it, you need to edit every single page. I'm looking for a way to have a single html file inserted in several page layouts. – GuayoMena Jan 14 '16 at 13:00
  • Read my post. Use the Content Link property of the Content Editor Web Part to point to a file in your style libray. Only one file to change. – teylyn Jan 14 '16 at 21:14
  • Absolutely right! That's exactly what I was looking for. I didn't know about that option. Do you know if there is a way to avoid wrapping the content in a table? Thanks! – GuayoMena Jan 22 '16 at 8:03

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.