You are calling get_page_by_title( $page_title )
already. Use it!
if ( ! get_page_by_title(
_x( 'Homepage Template', 'home page title', 'your_theme_textdomain' )
)
)
{
// create the page
}
Do not delete user content on theme deactivation. The user might have put much energy into that page, and maybe he is not aware you delete his work.
But I would not even create that page. Use a home.php
for the newest blog posts and a front-page.php
for the front page. Customize that and let the user choose any page.
Now, when your users rename the page and try another theme before switching back you don’t have to recreate the page with just a different title.
Update in response to your question update
Create the templates for the home page in a separate directory, for example /front-templates
. Then offer those templates as a choice in the customizer and save the template name in the theme options.
In your front-page.php
check for the option and include the matching template.
Sample code
$template = get_theme_mod( 'front-page-template', 'default' );
locate_template( "front-templates/$template.php", TRUE, TRUE );
Now you don’t have to create a new page, because front-page.php
will be used automatically on the front page.