How to import articles from the old station table once, if the fields do not match
When exporting tables from the old station to batch import into the new system, it is the norm rather than an exception for fields not to match. The processing method has a fixed sequence: first decide which channel to use, then fix the necessary mapping columns, then define a default value strategy for the custom fields that do not match, and finally use the ability to search by title to avoid duplicate imports. Skipping the first step and directly modifying the table will usually require two rounds of changes.
Choose the channel first and then talk about mapping
Batch import supports two channels: ZIP compressed package and Excel table. Both have different functions and are not an either/or relationship.
| Scene | Suggestion channel | Reason |
|---|---|---|
| Articles with attachments and illustrations need to be migrated together. | ZIP compression package | Attachments and the main text can be matched in the same batch. |
| Plain text articles exist as table columns. | Excel spreadsheet | The mapping from columns to fields is natural, convenient for batch verification. |
| It is necessary to connect with external systems and programmatic import. | Import Interface | First, check if it already exists before deciding whether to write. |
| The field structure of the old station is completely unclear. | Lead a small batch first. | Use a small number of samples to expose mapping issues. |
Select the channel after mapping because the two channels can carry different information: the archive can carry the correspondence between attachments and files, while the table can only carry the content in the columns. If you find that the attachments are missing after changing the table, you have to start over again.
The three columns that must be mapped
No matter how chaotic the old site structure is, first fix these three columns: title, alias, and category.
The title determines the identity of the article, and also determines whether the subsequent query by title can find the existence; the alias determines the online address, and the wrong mapping of the alias will cause the address to change after import, which will affect the historical links and inclusion; the category determines the page attribution and the display of the list page, and when the category does not match, the article is there but cannot be found.
The three columns can be left blank first, but do not compromise on these three columns. When the column name of the old station is inconsistent with the new station category name, a name correspondence table should be made first, rather than letting the import guess.
How to deal with the mismatch of custom fields
The custom content model supports flexible content structures, fields can be defined according to the site, so there are two ways to handle fields that 'exist in the old site but not in the new site': one is to add a custom field in the new site to accommodate it, which is suitable for the field to still participate in display or filtering later; the other is to merge the content into the main text, which is suitable for just supplementary information.
The criteria are whether it needs to be read separately. If it needs to be filtered by the list or participate in template tag output, it goes through the field; if it's just for display, it goes into the main text.
The strategy for matching fields that do not match should be specified: leave blank, provide a fixed value, or extract from the text. This should be written in advance in the import instructions, otherwise, the result of bulk import will have half empty values and half chaotic values. The deleted content can still be recovered from the recycle bin, but cleaning up the chaotic batch data is more time-consuming than recovery, so it is better to run through a test batch first.
Check for duplicate titles after import
The most common problem with batch importing is duplication. The document content import interface /api/import/archive supports querying whether it already exists by title, and the correct usage of this feature is to check it once before writing: update or skip if matched, and only write if not matched. Placing duplicate checking after importing turns it into creating duplicates first and then cleaning them up.
Check after import: sampling in three steps: randomly select several articles to verify the consistency of the title and alias with the table; verify the correctness of the category attribution; check if the attachments of articles with attachments are in place. The sample size does not need to be large, but it should cover the categories that do not match the fields, as problems are always concentrated at the boundaries.
Common questions
Which columns are supported by Excel table import?
It supports mapping columns to basic fields such as title, alias, category, and custom fields. The key is to define the correspondence between column names and new system fields in advance, and the columns that are not matched will be ignored.
What method should be used for articles with images?
Use a ZIP archive. The attachments and the main text are in the same batch, maintaining the corresponding relationship; the table channel can only express text columns.
How to roll back if the import is incorrect?
Single-item deletion can be restored to the recycle bin; for batch errors, it is recommended to check for duplicates before re-importing in batches, and decide whether to skip or write by querying the title to see if it already exists, which is more time-saving than cleaning up one article at a time.
What should I do if the old site field is more than the new site?
分流:To participate in filtering and display, supplement with custom fields; for only explanatory purposes, merge into the main text; discard those with no practical use directly.