I have added some taxanomy vocabulary with terms in my local development server which I need in some modules. I want to get these vocabularies with terms auto inserted when ever I install these modules where I have used them. Is there a way I write some code in drupal module which inserts the taxonomy vocabularies and terms when ever I install the module.

Thanks for your suggestions.

1 Answer 1


Rather than writing code, I use the Taxonomy CSV module. It allows you to export and import taxonomy as CSV files. You can use the module's user interface or do it by command line with Drush to speed things up even more.

Initial configuration can be a little tricky, but it's able to preserve tree hierarchies and order, etc. so a bit of complexity is to be expected.

  • 1
    Thanks Patrick, I need to add 5-6 terms in a single vocabulary so using a module for this will be complex as per requirements.
    – Umar
    Commented Apr 30, 2012 at 11:01
  • 1
    +1 CSV import is much more efficient than coding a lot of the time. @Umar If this won't work for you check out the taxonomy_vocabulary_save() and taxonomy_term_save() functions, they should give you a good starting point.
    – Clive
    Commented Apr 30, 2012 at 11:26

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.