Replace URLs from WordPress
WordPress makes it easy to create internal links. However, when Sourcing Gatsby from WordPress to GitHub Pages, you instead end up with external links that need to be replaced. Luckily enough, there is a simple way to accomplish this using the gatsby-source-wordpress plugin you already have installed. Here’s how.
Add the following lines to your gatsby-config.js file under resolve: gatsby-source-wordpress
.
searchAndReplaceContentUrls: {
sourceUrl: "url_to_wordpress",
replacementUrl: "url_to_gh_pages",
},
And deploy
yarn deploy
Now let’s see if it works.
A recent post creating a contact form has a link to the contact form. If it works, then these links should navigate to a page hosted on GitHub Pages.
If you replace url_to_wordpress and url_to_gh_pages in the snippet above, it should world. Mine does.
Sources
Previous: Create a contact form
...