Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i can provision a aspx page using the element.xml in the modules folder.

But how can i do to provision a html file that would contains code into a page library?

<Module Name="myModuleName" SetupPath="SiteTemplates\SPS" Url="Pages" >
        <File Path="default.aspx" Url="default.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
            <Property Name="Title" Value="PmyTitle" />
            <Property Name="ContentType" Value="My Location Page" />
            <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/rich.aspx, My Location Page Layout" />
            <Property Name="PublishingPageContent" Value="" />
        </File>

    </Module>
share|improve this question
    
You can provision files of any type to SharePoint document libraries, using same CAML. There is no difference... Have you tried similar code pointing to the html file? –  Andrey Markeev Jan 24 '12 at 22:35
add comment

1 Answer

up vote 2 down vote accepted

Just put the html file containing the markup into the module as normal, don't specify any properties other than title, it will use the deault content type.

<Module Name="myModuleName" SetupPath="SiteTemplates\SPS" Url="Pages" >
    <File Path="default.html" Url="default.html" Type="GhostableInLibrary">
        <Property Name="Title" Value="PmyTitle" />
    </File>
</Module>

To serve the raw html file you'll need to change the file handling for the web app to permissive.

If you'd like to put content into a provisioned aspx page then html encode the content:

<Module Name="myModuleName" SetupPath="SiteTemplates\SPS" Url="Pages" >
    <File Path="default.aspx" Url="default.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
        <Property Name="Title" Value="PmyTitle" />
        <Property Name="ContentType" Value="My Location Page" />
        <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/rich.aspx, My Location Page Layout" />
        <Property Name="PublishingPageContent" Value="&lt;div&gt; HTML encoded content goes here &amp; rocks! &lt;/div&gt;" />
    </File>
</Module>
share|improve this answer
    
thanks but can i provision a html file with code? –  user472285 Jan 25 '12 at 8:36
    
You need to put the default.html file containing your markup into a module and provision using the first of my code samples there. I am of course assuming that you only mean HTML and javascript as code. –  GavinB Jan 25 '12 at 19:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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