7

How would you go about creating a large number of nodes from a large number of html documents?

I am trying to create something similar to a book and have a lot of .docx files on my computer. I am aware I should use a wysiwyg editor to clean up the formatting and make it look like I want saving it as HTML. However there is the issue of getting all the .html files uploaded as nodes without having to copy-paste 200+ times.

Any ideas?

3 Answers 3

10

The module that appears as most suitable for you is called HTML import. This module will divide one single large HTML document into a structured Drupal book where the heading level hierarchy is respected. This module works with HTML exported from Word; HTML document converted from PDF as well as HTML document exported from Adobe InDesign.

This makes it possible to use a single HTML page, created in a word processing program and saved as HTML, or other structured HTML, to create a multipage Drupal book in a single step. You actually need to collate the output from all your .docx files into a single HTML-file before converting to HTML to use HTML import in a single step.

In case your requirements are beyond what HTML import is capable of, below is a list of all the (usable) Drupal modules I am aware of that can be used to bulk import HTML (and some other formats) into a Drupal site:

  1. HTML import - Import a single HTML page created from MS Word and split it up into an hierarchical Drupal book structure consisting of a set of interlinked Drupal nodes.
  2. HTML2Book - This also imports a single HTML page and split it up into an hierarchical Drupal book structure consisting of a set of interlinked Drupal nodes, but requires you to clean up the tagsoup created by MS Word first.
  3. Import HTML - Import all of an existing, static HTML-site into a Drupal site as nodes.
  4. Feeds - Import or aggregate data as nodes, users, taxonomy terms or simple database records.
  5. Migrate - Provides a flexible framework for migrating content into Drupal from other sources, including HTML.
  6. Node import - Allows users to import content (node, user, taxonomy) from CSV or TSV files. Requires you to convert from HTML to CSV. (no Drupal 7 version)

Of these, the simplest to use are HTML import and HTML2Book. However, both can only handle a single HTML page. For more complex conversion tasks, where you need to convert a large static HTML-site made up of several interlinked pages, one of the other modules may be more suitable.

Also: Whatever tool you use, never experiment with bulk import on a production site. Unless you're a lot more clever than me, there are going to be false starts and botched imports. Cleaning up thousands of nodes damaged by an import gone wrong is not fun. Always experiment with bulk import on a throwaway staging site that just can be discarded wholesale when things go wrong. Transfer the settings and do the import on the production site when you're sure you have a working set-up.

3
  • Thank you for the thorough answer! However I am using drupal 7 and already have a site set up (took quite a while to configure it.. so I am very much against creating a new drupal site). Feeds seems to be the only real option, however it seems very complex to use. Could you possibly elaborate on its use or are there any tutorials that are easy to read for a time-pressed fellow?
    – Ithxi
    Commented May 14, 2014 at 6:03
  • 1
    @Ithxi, I've used Feeds for a number of bulk import projects and to import HTML. make sure you tick "Allow all HTML tags". I am not aware of any tutorials describing the process in detail. This site is for basic Q&A, not detailed tutorials (nor do I have the time to write one). Feeds is indeed a beast that has rather rough edges. On the other hand, installing a throwaway Drupal 6 on localhost is (IMHO) quick and simple. If I had to choose between configuring Feeds to import HTML, and to set up a throwaway Drupal 6, I would opt for the latter. Commented May 14, 2014 at 6:11
  • I suppose it is an answer. But jeez it is horrible that there isn't a better way to do this? Someone must have faced the same issue and created a solution... Thanks for the answer though - I will mark it as answered in a couple of hours if no other answers show
    – Ithxi
    Commented May 14, 2014 at 19:12
3

If you have a lot of docx files(which you do), then it is really worth the effort to write a custom migration class using the migrate module. Something similar has been done before and documented.

2

Here is a nice tutorial for learning how to use feeds. It is really quite straightforward. http://mustardseedmedia.com/podcast/episode55

Please note that it doesn't cover how to import html docs but it should get you pretty far down the road.

Also, you really should learn how to use backup and migrate module ( https://drupal.org/project/backup_migrate) so you can easily backup and restore your database if you break something. I would also recommend you take the time to setup an extra copy of your site that you can experiment on. It is very frustrating when you break something and can't find your way back.

Selwyn

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.