Import a folder containing HTML files and images to Wordpress

I have a folder containing some HTML files with images and links between these HTML files. I'd like to import this folder to Wordpress such that each HTML page becomes a Wordpress page (that can be edited later) and the links between them is kept correctly. What is the best way to do that?

Topic import bulk-import plugins Wordpress

Category Web


It depends on what the HTML contains. You might be able to create a script that reads each HTML file, inserts a Page, adds Media, and populates the content - but that will likely be more effort than manually setting the pages up yourself in the Editor.

I'm not sure you could fully script the links as content, unless you first create a Page for each HTML file and save its slug, then populate the content of each Page separately (so its slug already exists and will point to a valid URL).

HTML can contain so much, and WordPress themes usually output a sitewide header and footer - so your opening <html> tag, the <head></head> tag, etc. are likely not to be something you want pulled into the actual Page content. If you have a lot of custom elements - such as CSS stylesheets or JS files - you may need to create blocks for those, or find another way to present the content, like creating Page templates in your (child) theme.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.