...

/

Advanced SEO Strategies for Astro Projects

Advanced SEO Strategies for Astro Projects

Learn what we should keep in mind when handling builds in Astro to further improve SEO.

When it comes to building an Astro project to create static assets for end users, we need to keep in mind that we can make additional adjustments to our build process to further improve SEO. In this lesson, we’ll take a look at two commonly used Astro plugins that can help us improve the overall SEO of the project.

Generating sitemap

Sitemaps are essential for search engines to better understand the structure of a website. Search engines can use these files to crawl a site more easily. These XML files list out all the accessible pages on a site, providing metadata about each page. These XML files have the following structure:

Press + to interact
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
>
<url>
<loc>https://example.com/</loc>
</url>
<url>
<loc>https://example.com/contact/</loc>
</url>
<url>
<loc>https://example.com/latest-post/</loc>
</url>
<url>
<loc>https://example.com/1st-recommended/</loc>
</url>
</urlset>

Each sitemap consists of a root urlset element, which defines an arbitrary number of the url elements. The urlset element can define a number of schemas using the xmlns attribute. Each url needs to have a loc element inside it, with the full URL pointing to a location. The sitemap given above represents part of the URLs created in the project for this course.

Let’s see how we can enable sitemap ...