A
A
Alexey2020-04-27 16:57:09
Create a sitemap
Alexey, 2020-04-27 16:57:09

How to create an auto-generated sitemap for images?

I have a gulp task that creates an auto-generated sitemap.xml for links. I also need to create a sitemap-emage.xml for all images on the site so that it is also auto-generated when all tasks are launched.
I saw in the documentation (httpswww.npmjs.compackagegulp-sitemap) that you need to switch the image flag to true (For generate sitemap for images per page, just enable images flag to true) , but I did not understand where this flag is located at all. The structure of my tusk is basically the same as there.
I saw how to solve this issue with the help of services, but I would like to learn a more delicate solution to this issue, especially since the pictures on the site can change, and I don’t want to download a new sitemap for images through the service.
If there are any other solutions to this issue, albeit without gulp, then I'm ready to consider them too.
I am attaching part of the code of my gulpfile.js

gulp.task(sitemap, function () {
    gulp.src(app.html, {
        read false,
    })
        .pipe(
            sitemap({
                siteUrl httpszaoks.ru,
                changefreq daily,
                priority function (siteUrl, loc, entry) {
                    let splitedLoc = loc
                        .split()
                        .slice(2)
                        .filter((elem) = elem != );
                    let priority = 1;

                    for (let i = 0; i  splitedLoc.length; i++) {
                        if (i == 0) {
                            continue;
                        } else {
                            priority = priority - 0.2;
                        }
                    }

                    priority = priority.toFixed(1);
                    return priority;
                },
            })
        )
        .pipe(gulp.dest(app));
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question