Add and generate sitemap
URL of images shouldn't contain pub directory.
<image:image>
<image:loc>
https://example.com/media/catalog/product/s/a/sample-product-img.jpg
</image:loc>
<image:title>Sample product</image:title>
<image:caption>Sample product</image:caption>
</image:image>
<PageMap xmlns="http://www.google.com/schemas/sitemap-pagemap/1.0">
<DataObject type="thumbnail">
<Attribute name="name" value="Sample product"/>
<Attribute name="src" value="https://example.com/media/catalog/product/s/a/sample-product-img.jpg"/>
</DataObject>
</PageMap>
<image:image>
<image:loc>
https://example.com/pub/media/catalog/product/s/a/sample-product-img.jpg
</image:loc>
<image:title>Sample product</image:title>
<image:caption>Sample product</image:caption>
</image:image>
<PageMap xmlns="http://www.google.com/schemas/sitemap-pagemap/1.0">
<DataObject type="thumbnail">
<Attribute name="name" value="Sample product"/>
<Attribute name="src" value="https://example.com/pub/media/catalog/product/s/a/sample-product-img.jpg"/>
</DataObject>
</PageMap>
Is not exactly the same issue, but might be related to: https://github.com/magento/magento2/issues/1146
@RG-1 Unfortunately I could not reproduce this issue. May you please advise if this problem is still relevant for latest release Magento 2?
I haven't verified it it is still true on the latest version, but we definitely had the same problem with Magento 2.1.3 or 2.1.4 if I remember correctly.
We could work around it by setting the configurations:
{{unsecure_base_url}}media/
{{secure_base_url}}media/
By default, these fields are empty and the 'pub' directory part was getting added to the image paths in the sitemap.xml files.
Be aware that you should test this with the 'pub' directory being used as docroot.
@IlnitskiyArtem: not sure if this helps? If you want I can test again using a plain vanilla Magento setup.
@IlnitskiyArtem Ok, I was able to reproduce this again in Magento 2.1.7
I forgot this bug was triggered by the cronjobs. If you generate the sitemap.xml file using the adminhtml, there is no problem, it only happens when you let the sitemap.xml file generate using the cronjobs.
So steps to reproduce:
php bin/magento cron:run
a couple of times until the generation of the sitemap.xml is triggered by this commandWould be great if this could be fixed! The workaround mentioned above gets us around the issue, but not all Magento customers will discover this workaround, so a fix would be appreciated :)
Thanks!
@hostep
Thanks for the additional information!
We've created internal ticket MAGETWO-70150 to address this issue.
@RG-1, thank you for your report.
We've created internal ticket(s) MAGETWO-70150 to track progress on the issue.
Why hasn't the issue been fixed in 2 years?
Still a bug in 2.1.7
1) /Pub/ is still being added to image urls causing SEO problems
2) Sitemap lastmod date does not change when you add products to or edit categories
@kamilszarmach thank you for joining. Please accept team invitation here and self-assign the issue.
After founding the obscure setting 'document_root_is_pub' => true
to fix my sitemaps because my site is server from the pub
folder I see the images are also starting with 'pub' in the sitemap.xml
I can't believe this still hasn't been fixed.
My quick workaround in NGINX:
RewriteEngine on
RewriteRule ^pub/(.*) /$1 [PT]`
Still exist in 2.2.6
Backend generated sitemap.xml contains /pup/ in image src, when shops root is in /pup/.
Workaround by hostep works for me. Set generation time some minutes past to current time and generate sitemap with "bin/magento cron:run" generates sitemap without /pup/ in image path. Then I set frequency to monthly to not overwrite by automation.
Another workaround for those who still are looking for a solution for this is to create a dummy pub symlink in the pub directory, like so:
$ ln -s . pub
Hi @krisdante. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.[ ] 2. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
This is now (2.3.2) duplicate of #24484 as the reason of 404 is different.
There is no pub directory in the URL anymore as of 2.3.2.
See the sitemap below:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>http://creativeshop.me/foo.html</loc>
<lastmod>2019-09-15T11:39:26+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>
http://creativeshop.me/privacy-policy-cookie-restriction-mode
</loc>
<lastmod>2019-09-15T11:32:03+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.2</priority>
</url>
<url>
<loc>http://creativeshop.me/bar.html</loc>
<lastmod>2019-09-15T11:45:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
<image:image>
<image:loc>
http://creativeshop.me/media/catalog/product/cache/5ac664ada4c750d9cbcf6e03d9aa8773/a/n/animal-racoon.jpg
</image:loc>
<image:title>Bar</image:title>
</image:image>
<PageMap xmlns="http://www.google.com/schemas/sitemap-pagemap/1.0">
<DataObject type="thumbnail">
<Attribute name="name" value="Bar"/>
<Attribute name="src" value="http://creativeshop.me/media/catalog/product/cache/5ac664ada4c750d9cbcf6e03d9aa8773/a/n/animal-racoon.jpg"/>
</DataObject>
</PageMap>
</url>
</urlset>
The 404 problem is fixed by #24605
Hi @RG-1. Thank you for your report.
The issue has been fixed in magento/magento2#24605 by @krisdante in 2.3-develop branch
Related commit(s):
The fix will be available with the upcoming 2.3.4 release.
@magento-engcom-team You also need to release a patch for Magento 2.2.9 EE as this effects us enterprise customers also...
Most helpful comment
Why hasn't the issue been fixed in 2 years?