5

I am taking on a project where I need to build a static website (due to hosting restrictions).

I thought of trying to do this by building a WP site on my computer, then creating a sitemap, and then ripping that site, and finally uploading the files to the host.

Any better suggestions on how to do this? (or any good reason why I shouldn't even try)

5
  • 1
    What are the restrictions? It could help us come up with another idea. Commented Aug 23, 2010 at 22:29
  • For what I know of now (and I'll know more in only two weeks) : No DataBase. I think maybe PHP (but I don't know yet). Thinking about that, could it be possible to use a DB from another host?
    – Tal Galili
    Commented Aug 23, 2010 at 22:36
  • 1
    Yes, if the DB supports connections from other hosts, that's easily possible. And that might be the easiest solution for you.
    – hakre
    Commented Aug 23, 2010 at 22:47
  • Interesting Hakre. I'll check my options and work according to that.
    – Tal Galili
    Commented Aug 23, 2010 at 22:54
  • Does this work for forms, eg "leave a comment" under each post? Or user registration? I'm guessing anything where a user would do something that changes the db would break?
    – user4849
    Commented Mar 25, 2013 at 17:52

3 Answers 3

5

I am doing this right now (still in process). The best setup seems to be:

  1. Add the .html extension on posts - easy, just use custom post pattern

  2. Add the .html extension on pages - need a plugin for that, if you use pages

  3. Disable feeds (in function.php by removing headers for it)

  4. Use wget from the command line:
    wget -x -nH -P scraped -np -k -R php -E -X wp-content,wp-includes -m http://address/siteroot/

    This sucks down your site, changes WordPress-style directory URLs to .html URLs, changes internal links to relative, etc. Feed URLs on all levels (root, category, article, etc) mess this up, which is why they have to be removed.

    Obviously, the assumption is that the site is fully reachable from the root. If that's not the case, use a sitemap plugin (as you yourself mentioned) and scrape from there.

  5. Run some sort of processor to remove http://address/ or change it to absolute root of your static site. If you need to move directories about (e.g. media/uploads), that's a little more difficult.

This should get you about 80% of the way.

If you do end up going this way, track me down when you know more and I will share the rest of the setup from my work computer. (If more than one person needs this, rank this up and I will put it somewhere public in a month or so, once fully done.)

3
  • I am marking your answer as "the answer" since: 1) you made a great answer. 2) I hope you would return to update the answer on how it worked up at the end :). Thanks for sharing the knowledge!
    – Tal Galili
    Commented Aug 24, 2010 at 0:59
  • Glad you found it useful. I will update this post when I have some more info. Commented Aug 24, 2010 at 21:31
  • Just an update that the original answer strategy did work. Couple of additional hints is not to link to WordPress RSS feed from template as that confuses wget. Download it as a separate command. Also, Wordpress bakes in full URLs for missing resources, so it is useful to do a search/replace after downloading to remove the host part: /bin/find scraped-en/ -type f -exec sed -i 's|hostname[^/]*||g' {} \; Commented Dec 16, 2010 at 19:38
2

From your comment I believe there are two better options, that will keep development time down and your sanity in check.

1) If you have PHP w/ PDO, then you could look at using this plugin http://wordpress.org/extend/plugins/pdo-for-wordpress/, which will let you use sqlite as a database. Note: Wordpress was designed around and for mysql, your results may vary using a different sql backend.

2) If all you have is some basic php modules. I would just create the site with a group of includes. To where you are creating a series of "templates" using php includes. I would have a php file for the header, footer, home page and inner page. If you have multiple inner pages. I would pull any similiar layouts out into a separate page and include those for each type of inner page. Then put all your content in the inner pages. Then with your index.php create some basic code that loads up the pages you want based on the URL coming in. You can use .htaccess with mod_rewrite (assuming apache) To convert nice urls to something like /about-us into /index.php?template=inner&page=about

2

Hi @Tal Galili:

If @Insanity5902's suggestions are not applicable then you could use HTTrack Website Copier to download a copy of the site and then upload the downloaded copy of the site to your server.

3
  • I was thinking of use it - thanks for the suggestion :)
    – Tal Galili
    Commented Aug 24, 2010 at 0:58
  • @Tal Galili: I used it in the past and it worked really well for most sites. It had trouble with strangely architected sites but it shouldn't have trouble with a WordPress site. The nice thing about it is it just works. Commented Aug 24, 2010 at 2:59
  • 1
    HTTTrack rocks, you might need some time to figure all options but it comes with help and it even allows you to update your static page later on. Give it a try, it's easier to use than wget if you like GUIs - not saying here wget is not powerful.
    – hakre
    Commented Aug 24, 2010 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.