Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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)

share|improve this question
1  
What are the restrictions? It could help us come up with another idea. –  Ryan Gibbons Aug 23 '10 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 Aug 23 '10 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 Aug 23 '10 at 22:47
    
Interesting Hakre. I'll check my options and work according to that. –  Tal Galili Aug 23 '10 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? –  barrycarter Mar 25 '13 at 17:52

3 Answers 3

up vote 5 down vote accepted

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

1) HTML extension on posts - easy, just use custom post pattern

2) 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) wget -x -nH -P scraped -np -k -R php -E -X wp-content,wp-includes -m http://address/siteroot/

That last one 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).

share|improve this answer
    
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 Aug 24 '10 at 0:59
    
Glad you found it useful. I will update this post when I have some more info. –  Alexandre Rafalovitch Aug 24 '10 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' {} \; –  Alexandre Rafalovitch Dec 16 '10 at 19:38

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.

share|improve this answer
    
I was thinking of use it - thanks for the suggestion :) –  Tal Galili Aug 24 '10 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. –  MikeSchinkel Aug 24 '10 at 2:59
    
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 Aug 24 '10 at 12:45

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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