v1.5.1
Analytics and SEO
When you are nearing launch for your Canopy IIIF-powered site, there are a few additional steps you can take to improve your site's visibility and track usage. This guide covers how to set up a sitemap, configure robots.txt, and integrate Google Analytics for tracking site traffic.
Sitemap
On every build, a sitemap is generated automatically at the root of your site. This helps search engines discover and index your pages more effectively. If your site URL is https://example.com, your sitemap entry point remains https://example.com/sitemap.xml, making it easy to submit to Google Search Console or other webmaster tools.
Canopy automatically breaks sitemaps into chunks of 1,000 URLs, per search engine recommendations. Each chunk is written to a numbered file (sitemap-1.xml, sitemap-2.xml, etc.), and sitemap.xml is always a sitemap index that points to the generated files even when you only need a single chunk:
<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap> <loc>https://example.com/sitemap-1.xml</loc> </sitemap> <sitemap> <loc>https://example.com/sitemap-2.xml</loc> </sitemap></sitemapindex>If you only have a single chunk, the index simply references sitemap-1.xml, so search engines still find your complete list with the standard entry point.
Robots.txt
A robots.txt file is also generated at the root of your site. This file provides instructions to web crawlers about which pages or sections of your site should not be crawled or indexed. The default configuration disallows all crawlers to access all parts of your site while it is in development. Once your site is live, you may want to modify this file to allow access to certain sections or the entire site.
User-agent: *Allow: /Google Analytics
To track user interactions and gather insights about your site's traffic, you can integrate Google Analytics using the <GoogleAnalytics> component. This component simplifies the process of adding the necessary scripts to your site. The <GoogleAnalytics> component outputs an analytics loader script for the ID you provide. If you prefer a different analytics solution, you can manually add the required scripts in your site's global Head export.
Usage
import {CanopyHeader, CanopyFooter, GoogleAnalytics} from "@canopy-iiif/app/ui"; export function Head() { return ( <> <Meta siteTitle="Site Title" /> <Stylesheet /> <GoogleAnalytics id="G-XXXXXXX" /> </> ); }Props
| Prop | Type | Required | Notes |
|---|---|---|---|
id | string | ✅ | Google Analytics ID (e.g., G-XXXXXXXX). When omitted, nothing renders. |