· 3 min read · updated
A robots.txt that never worked, and SEO on purpose
Decided issue 3 from the start of the learning path: the site is findable. Only /mascot (a review sheet, not a page yet) says noindex.
What we did
- Decided issue 3 from the start of the learning path: the site is findable. Only
/mascot(a review sheet, not a page yet) saysnoindex. - Removed
static/robots.txt: it had never done anything (see below). Seo.svelte, one component every page uses instead of its own<svelte:head>:<title>, description, canonical URL, Open Graph tags and a Twitter card. No image yet, so link previews are text cards (my call, an image can come later).- Titles end in "Alfonso Baeza" instead of "AB":
CV builder · Projects · Alfonso Baeza. sitemap.xml, a prerendered endpoint built from the same lists as the pages (sections, projects, Awesome lists, posts, tags, Devlog entries), withlastmodwhere there's a date.- Devlog entries get a description from their body:
summary()incontent.tstakes the first paragraph or list item, as plain text, cut at a word under 160 characters. - Lighthouse SEO, accessibility and best practices 100 on home, the CV builder and an entry.
/mascotgets 63 for SEO, on purpose: "blocked from indexing".
What I learned
- Crawlers only read
robots.txtat the root of the host:abafdez.github.io/robots.txt. My site is a project site under/portfolio/, so my file at/portfolio/robots.txtwas never read, and the root one is a 404. TheDisallow: /I thought was hiding the site did nothing. On a project site, the<meta name="robots">tag on each page is the only switch I control. Disallowandnoindexaren't the same anyway.Disallowstops crawling, but a blocked URL can still be listed if other sites link to it.noindexkeeps a page out of results, and the crawler has to be allowed in to read it.- While prerendering there's no real request, so SvelteKit makes up
page.urlwith the originhttp://sveltekit-prerender.paths.originin the config (in SvelteKit 3 it's underpaths, next tobase) makes it the real one, so canonical andog:urlare absolute URLs that work. - The canonical URL leaves out the query:
/projects/cv?profile=supportis the same page as/projects/cv. - A sitemap can't be announced in a
robots.txtI don't control, so it has to be submitted by hand (Google Search Console).
Links
- Google: robots.txt introduction
- Google: Block indexing with noindex
- The Open Graph protocol
- sitemaps.org protocol
- SvelteKit: configuration, paths
Next
- Submit
sitemap.xmlin Google Search Console once this is deployed. - Phase 9 goes on: Vitest for
content.ts(summary()is a good first test), Playwright smoke tests, and tests in CI.