Archived topic
Remove #main from attachment page URLs
3 replies · Started by Alexander on September 20, 2019
Hello,
when I switched to GeneratePress, I noticed that a URL parameter (or whatever it is called) "#main" is appended to URLs of my attachment pages. This didn't happen with my old theme.
Example: https://www.alex-kunz.com/photos/summer-dawn-at-garnet-peak/#main
I didn't think of it much at first, but it seems that this has caused Google to drop >5000 attachment pages with photos from their search index. Yikes! I'm running a photography site and DO want the attachments to be indexed (Yoast SEO is configured to include them in the sitemap).
https://www.dropbox.com/s/xbkhotp69yn9ski/wmc.png?dl=0 <-- find the date when I switched to GeneratePress... :-P
How do I remove this #main thing from the attachment page URLs?
Thanks
Alex.
Hi there,
Can you try this PHP snippet?
https://generatepress.com/forums/topic/main-at-the-end-of-every-attachment-url/#post-978575
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know :)
Oh, you had that question already in the past - sorry that I missed this. The solution works for me as well.
Thank you, Leo!
No problem :)
Not an easy one to find!