The <apex: insert> is another important templated component used for declaring the named area defined by the <apex: define> component in another VF page. To share the data between multiple pages, we have to use this component with the <apex: composition> and <apex: define> components.
The <apex: insert> component has the following attributes on the VF page:
1. name
The name is a string-type attribute used for specifying the name of the matching <apex: define> tag providing the content to be inserted into this VF page.
Let's take an example to understand how we can use the <apex: insert> component on the VF page:
ApexDefineExample.vfp
<!-- create apex page to understand the <apex: define> component -->
<apex: page >
<!-- use <apex: composition> for specifying the template-->
<apex:composition template="ApexInsertExample">
<!-- use <apex: define> for adding header and body-->
<apex:define name="header">(page)Header of ApexDefineExample Start.</apex:define>
<apex:define name="body">(page)Body of ApexDefineExample Start.</apex:define>
</apex: composition>
</apex: page>
ApexInsertExample.vfp
<!-- create an apex page that acts as the template-->
<apex: page >
<!-- use outputText and insert component -->
<apex:outputText value="(template) This is before the header"/><br/>
<apex:insert name="header"/><br/>
<apex:outputText value="(template) This is between the header and body"/><br/>
<apex:insert name="body"/>
</apex: page>