How to convert an HTML website to WordPress
So, you are looking forward to moving your website from HTML to WordPress. However, migrating a static site to WordPress doesn’t mean that you will have to say goodbye to your existing site. You can move your HTML site to WordPress easily while keeping the design, content, and even SEO rankings as they were.
This post uncovers a step-by-step process on moving an HTML website to WordPress:
Preparing for HTML to WordPress Conversion The first and foremost thing is to choose the right hosting plan that best fits your requirements. Once you’ve purchased a plan, you will need to install WordPress and log into WordPress’s admin panel.
Before you start the site conversion, you must create a backup of your existing website data. It will empower you to eliminate all the migration risks. You can use a hard disk, flash drive or any other medium or object for data backup.
When you have a backup of your website, it’s time to create a WordPress theme. There are two options available:
- Manually create a WordPress theme according to your static HTML website.
If your motive is to not only move the content from your HTML website into WordPress but also want the existing design, you will need to create a custom theme. Thankfully, this is not as difficult as it sounds at first. It involves the simple process of setting up some folders and files, copying & pasting, and then uploading the content. Here, you will need a code editor i.e. Notepad++ or Sublime. Moreover, you will require HTML site’s directory and new WordPress install’s directory.
- Create a New Theme Folder and Necessary Files On a desktop, simply create a new folder to store your theme files. Now, create the below-mentioned files in a code editor. You will not need to do, just leave them open for further coding.
Copy current CSS into New Stylesheet If you are looking forward to imitate a design, you will need to play with the CSS. So the first file you should edit is your Style.css file.
You should add the following code to the top of your file:
/* Theme Name: Replace with your Theme's name. Theme URI: Your Theme's URI Description: A brief description. Version: 1.0 Author: You Author URI: Your website address. */
After this section, just paste your current CSS below and save the file.
- Separate your existing HTML
Before we go further, let’s see how WordPress works. WordPress uses PHP to call and recover the data from its underlying database. Each file that is mentioned in this tutorial is created to tell WordPress which part of your web content needs to be shown and where. So, here what you need to do is just copy and paste your existing code into the individual files, you’ve just created and let WordPress know where to display them. Follow all the below mentioned steps to perform this:
- First, open the index.html of your existing website. Highlight the section from the top to the div class=”main” tag. Now, copy & paste this section into your header.php file and save.
- Again, open your index.html file and highlight the class=”sidebar” element and everything inside it. Now, copy and paste the copied part into your sidebar.php file and save.
- Now, select everything that comes after the sidebar and copy & paste this part into your footer.php file and save.
- In the end, copy everything that’s left in your index.html file and paste it into your index.php file and save.
• Finalize Your Index.php File
In order to settle your new index.php file, you need to make sure that it calls up all the other section that are kept in other files you’ve created.
Place the following line of php. at the top of your index.php file:
<?php get_header(); ?>
Place following code to the very bottom of your index.php file
<?php get_sidebar(); ?>
<?php get_footer(); ?>
And last but not the least, you will need to add the primary bit of php that WordPress uses to showcase your content to the visitors.
Now, the final step is to add the below-mentioned code in the index.php.
<?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="post-header"> <div class="date"><?php the_time( 'M j y' ); ?></div> <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <div class="author"><?php the_author(); ?></div> </div><!--end post header--> <div class="entry clear"> <?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail(); ?> <?php the_content(); ?> <?php edit_post_link(); ?> <?php wp_link_pages(); ?> </div> <!--end entry--> <div class="post-footer"> <div class="comments"><?php comments_popup_link( 'Leave a Comment', '1 Comment', '% Comments' ); ?></div> </div><!--end post footer--> </div><!--end post--> <?php endwhile; /* rewind or continue if all posts have been fetched */ ?> <div class="navigation index"> <div class="alignleft"><?php next_posts_link( 'Older Entries' ); ?></div> <div class="alignright"><?php previous_posts_link( 'Newer Entries' ); ?></div> </div><!--end navigation--> <?php else : ?> <?php endif; ?>
- Now, save your index.php. You have done everything with the theme. All you need to do is upload it to your WordPress website.
- Put your new theme folder inside /wp-content/themes/ and go back to WP Admin > Appearance > Themes. Here you will find your newly created theme that should be activated now.
- Now, populate your new WordPress site with your old web content.
Step 4: Upload Your New Theme
When you have created your theme files and stored in your new theme folder, you will need to access your new WordPress directory.
- Install a pre-made theme and just move your content If the 1st process seems too difficult or time-consuming, then you can go with the other way. Rather than converting any design into a WordPress theme, you can take advantage of the themes available in the WordPress marketplace. • There is a wide range of free and premium themes available. You can choose the one that caters to your needs.
• When you’ve chosen the most suitable theme, you will need to go back to WP Admin > Appearance > Themes > Add New and install/activate new WordPress theme.
• Once you have done, you will have a new WordPress-powered website and theme. When you will see the preview of your website, there would be no content. So, the next step is to import your old site’s content.
• In WordPress Admin, go to Plugins and search for a plugin “HTML Import 2”. You can easily install this plugin and activate with the help of handy user guide.
After the plugin installation, you will have your old content live on WordPress website which is formatted by your new theme.
Conclusion By following all the above-mentioned steps, you can easily migrate your static HTML website into a WordPress site. Make sure your WordPress website is fully secured and created according to the guidelines of SEO.