I’ve recently migrated my site from WordPress to Hugo and have encountered some issues with URLs in my content. My old WordPress site had the following base URLs:
Old base URL: http://localhost/mitra
New base URL: https://www.example.com
Old asset base URL: http://localhost/mitra/wp-content/uploads/*year*/*month*/
New asset base URL: https://www.example.com/images/
After converting my content to Hugo format, I noticed that many internal links and asset URLs (especially images) still point to the old localhost URLs. I need to update these URLs to match my new Hugo site structure.
Example of the current content:
Currently, there is a surge in the sale of Cucak Rowo birds at [breeding farms](http://localhost/mitra/peternakan "breeding farms") across Indonesia.
![Image](images/indukan-300x169.jpg)](http://localhost/mitra/wp-content/uploads/2021/11/indukan.jpg)
Desired result:
Currently, there is a surge in the sale of Cucak Rowo birds at [breeding farms](https://www.example.com/peternakan "breeding farms") across Indonesia.
![Image](https://www.example.com/images/indukan-300x169.jpg)](https://www.example.com/images/indukan.jpg)
articles already converted into markdown and placed in post directory and i use this script to convert wordpress post into hudo .md files
I’ve been trying to manually update the URLs, but this is quite tedious given the amount of content. I’m wondering if anyone can suggest a more efficient method to batch update these URLs across my Hugo project. Perhaps using a script ,notepad++ or specific tool?
Any help or guidance would be greatly appreciated. Thanks in advance!
There’s no need to use complete, absolute image URLs in the MD files. If you place them were Hugo can find them (either in assets or static directory, depending on your partials and image render hook.
Using absolute URLs like you try to do is counter productive if you are running hugo server , too.
As @chrillek mentioned you schould not use hardcoded links but rely on Hugos rendering on markdown url ofc you will have to get your config right.
You will still need
Search replace of the old base url and there are mutiple options. Perl, sed, aek, grep. Also editors like notepd++ or vscode offer batch replace incl regex. But this is off topic and you will find your answer on stackoverflow or similar.
Put your images in a place where hugo can find it. static folder, assets or use the mounts option of hugo
Yes, I understand about that irkode. It’s just that the conversion result from wordpress-export-to-markdown has a format like the one I mentioned above. All attachments have been moved to the /asset/images folder. (im woking on windows )
The issue with the post URL that adds the image path like: