Recently, I wanted to use a HTML menu that the client could edit themselves for the navigation. Naturally, one would prefer that the client didn’t edit the master page but simply the HTML. The standard solution for this is to use an include – the client edits the HTML file which is included in the master page. So I went looking for how to include files in a master page.
The first thought is to just use an ASP include, which is server side and really the neatest solution. W3C Schools offers a very nice explanation on how to do this. However, when I tried to apply it, Sharepoint refused to show anything but an error screen, saying that I wasn’t allowed to use this include.
At first, I’d used a file with the HTML extension. I tried switching this to .txt and to .aspx, but the error stayed the same.
I tried using both the file and virtual include, as explained in the W3C article, but that didn’t help either.
The only potential solution I could come up with was putting the information in a Javascript file and then calling it via a script, but that gave two problems of its own:
- The client would have to wade through the Javascript markup just to edit the HTML – way overdone.
- The Javascript include doesn’t work too well with search engines like Google, which is a problem for a major external site like this one.
Finally I just decided to stick with the current solution. It looks like includes on master pages aren’t really possible.
