R – Sharepoint Site Template – Custom .aspx pages

custom-pagessharepointsitetemplate

I am creating a site template in Sharepoint. I also have some custom .aspx page, that I want to deploy in Layouts\myDirectory. Using my site template I will create a Web (SPWeb) that should use the custom pages and reference them by an url of the form http://site/MyWeb/MyCustomPage.aspx. How do I integrate the pages in my custom template?

Best Answer

Pages stored in the Layouts folder are Application Pages and should always only be referenced through the _layouts virtual directory

If you want to reference the page as http://site/MyWeb/MyCustomPage.aspx then it should be a Site Page

A site page can be put inside a feature or directly inside a Site Definition (even thought I recommend that you only use the Site Definition to activate features). The way you provision the page is throught the Module & File elements see MSDN