Dynamic to Static Website Conversion

Why you might want to do this

There are several situations where maintaining a dynamic website–one that uses PHP, a Content Management System (CMS), or some other server-side technology–is no longer desirable, though the website itself needs to remain.

  • The underlying technology is outdated or a security risk and cannot be easily upgraded.
  • The website is in its final form and updates or dynamic content are no longer needed.
  • The dynamic website uses excess system resources, and the amount of ongoing manual updates are minimal.

This document describes a process that either a customer or Michigan Tech IT staff can use to convert these kinds of websites.

What you'll need

  • Access to a computer with wget installed. Most campus Linux computers have this program installed, including these remote servers, accessible by SSH. See Connecting to a Linux Computer Remotely for more information on connecting.
    • login.mtu.edu
    • colossus.it.mtu.edu
    • guardian.it.mtu.edu
  • A destination for the static version of your website. This could be one of the following.
    • pages.mtu.edu can be used as a final destination or as a temporary location for testing the static version of your site. See more information on What is pages.mtu.edu.
    • A different location on your existing site, again as a temporary step while testing
    • A new location Michigan Tech IT has set up for the conversion
  • Familiarity with HTML. Though wget does most of the heavy lifting, there are some cases where editing HTML may be necessary.

Things to consider

There are some drawbacks of converting to a static site.

  • Features that use JavaScript or that do dynamic queries will no longer work.
  • Built-in site search will no longer work (though external searches should work normally).
  • Forms, such as contact forms, will no longer work.
  • Ongoing updates will be more difficult. If you anticipate needing to update the content or styling on the site after it's converted, this might not be a good option.
  • If your dynamic site has pages or files that are not linked elsewhere on your site, they won't be included in your static site. In order for wget to find pages and files, they must be linked (i.e., something a person could find by clicking links on your site).

Procedure

As an example, we'll walk through converting the site Why Study Forest-based Bio fuel in Michigan? website using pages.mtu.edu to check the conversion along the way. Adjust the web addresses and file paths as needed in the examples.

Do a test conversion

  1. Login to a Linux computer with wget installed. Change to a directory that will hold a test version of the static site.

    cd /local/my_web_files/jamyles

    mkdir static_test

    cd static_test

  2. Use wget to create a static copy of the site.

    $ wget -e robots=off --mirror --convert-links --adjust-extension --page-requisites --no-parent http://michiganforestbiofuels.org/

    This will take some time depending on the size of the website and the number of pages and files it contains.

Check the static site

  1. Visit the test site. The previous command creates a new directory based on the site name, so add that to the web address corresponding to your pages.mtu.edu page (or other location you're using to test). In this case, the test site created is https://pages.mtu.edu/~jamyles/static_test/michiganforestbiofuels.org/.

    1. Browse the site and check that any images and styles are displayed correctly.

    2. As you browse, check to make sure you don't end up on the live, dynamic site (http://michiganforestbiofuels.org/ in our example). This indicates a link wasn't converted correctly.

    3. Take note of features that may not work, such as those mentioned in the "Things to consider" section above.

  2. Look for files that weren't converted properly. Most commonly these will be files with links that were not updated by wget and instead still point at the live dynamic site. This may cause issues later, especially if the static site will end up at a different web address than the dynamic site.

    grep -R "//michiganforestbiofuels.org/" michiganforestbiofuels.org

  3. Edit files with incorrect links. For example, instead of:

    <link type="text/css" rel="stylesheet" media="all" 
    href="http://michiganforestbiofuels.org/modules/system/system.css" />

    links should look like:

    <link type="text/css" rel="stylesheet" media="all" href="modules/system/system.css" />

    Re-test by browsing the site after your updates.

  4. Note which dynamic pages don't work properly, such as search pages and contact forms.

Do the final conversion

  1. If possible, disable the dynamic pages identified in the previous step so they won't be included in the static site. Make sure any last updates to the dynamic site have been done.
  2. Repeat the wget command the testing section.

    $ wget -e robots=off --mirror --convert-links --adjust-extension --page-requisites --no-parent http://michiganforestbiofuels.org/

  3. Repeat any fixes and adjustments you did in the checking section.
  4. Move the site into its final location. You may need to pack up the mirrored files and copy them to another server (details will vary, and IT can assist with this part). Keep in mind that the "root" of your site will be inside the new directory created by wget. This command would create a zip archive suitable for unzipping in the root of a new site, or on your existing site after the dynamic site has been removed.

    cd michiganforestbiofuels.org

    $ zip -r ../michiganforestbiofuels_static.zip .

  5. Do a final live test of your site after it is in place.

References

Was this helpful?
0 reviews

Details

Article ID: 53021
Created
Tue 5/1/18 8:05 AM
Modified
Fri 6/15/18 8:58 AM