Hi @quinncooper88
Thanks for using Yoast SEO plugin and for creating the thread. We understand that you are noticing the error “error on line 2 at column 6: XML declaration allowed only at the start of the document” while opening the sitemap. We can see how this might give you pause. We are happy to take a look! Let’s see what is going on.
An empty whitespace or a blank line appears due to a conflict with another plugin or your theme. Usually, there is an empty space or a blank line before or after the closing PHP opening or closing tag, which shouldn’t be there. In your case, the first line of the sitemap and all the pages source code are having a blank line is causing this issue. See screenshot for your reference: https://ibb.co/R468ySrC
You can narrow down the exact source of conflict by performing a conflict check. Once you have identified whether your theme or a plugin causes the issue, please contact the developers of that theme or plugin for assistance in finding and removing the white space.
I installed the Health Check & Troubleshooting plugin and it says these are the issues under Site Health > Status:
– One or more recommended modules missing: PHP modules perform most of the tasks on the server that make your site run. Any changes to these must be made by your server administrator. The WordPress Hosting Team maintains a list of those modules, both recommended and required, in the team handbook(opens in a new tab). Warning The optional module, imagick, is not installed, or has been disabled.
– Opcode cache is not enabled: Opcode cache improves PHP performance by storing precompiled script bytecode in memory, reducing the need for PHP to load and parse scripts on each request. Enabling this cache can significantly improve the performance of your site.
I should also point out that I’m using a custom block theme (using Create Block Theme plugin). And I also built some custom blocks, but I don’t see anything in them that would be causing this issue.
I looked through all my php files (functions.php, hhc-blocks.php, blocks-manifest.php etc) to see if any of the php opening tags had whitespace and they don’t nor do they have closing php tags.
Okay I fixed the missing modules. I enabled imagik in my cPanel settings. That still doesn’t fix the issue. I have these plugins: ACF Pro, WP Migrate Pro, Regenerate Thumbnails, Reveal IDs, Sure Forms, Sure Mail, WP Super Cache (I have tried deleting the cache and deactivating this plugin), and Health Check & Troubleshooting.
Still having issues 🙁
I disabled all the plugins. That didn’t help
Given the nature of the issue, we’ll need to look at your setup. However, we are unable to do it here as this is a public forum. You could consider purchasing a Yoast SEO Premium subscription, as it includes email support. Then we can investigate the issue further, directly on your setup, privately.
Just wanted to give an update. I figured it out. I had a closing php tag in my hhc-blocks.php file. Removed that and now the site map works! Thank you everyone who replied.