Skip to content

fix: added seo sitemap for product pages#3151

Merged
zamanafzal merged 9 commits intomainfrom
zafzal/10755-seo-learn-product-pages
Apr 6, 2026
Merged

fix: added seo sitemap for product pages#3151
zamanafzal merged 9 commits intomainfrom
zafzal/10755-seo-learn-product-pages

Conversation

@zamanafzal
Copy link
Copy Markdown
Contributor

@zamanafzal zamanafzal commented Apr 2, 2026

What are the relevant tickets?

https://github.com/mitodl/hq/issues/10755

Description (What does it do?)

This PR implements SEO improvements for Learn product pages:

  1. Removes noindex, nofollow from course and program product pages to allow search engine indexing
  2. Adds product pages to the sitemap via a new products/sitemap.ts that fetches MITxOnline courses and programs from the /api/v1/learning_resources/summary/ endpoint
  3. Updates MITxOnline ETL to set the url field to Learn product page URLs (e.g., /courses/{readable_id}, /programs/{readable_id}, /courses/p/{readable_id} for programs with display_mode="course")
  4. Includes url in the summary API response for sitemap generation

Screenshots (if appropriate):

Screenshot 2026-04-03 at 5 39 04 PM Screenshot 2026-04-03 at 5 38 28 PM Screenshot 2026-04-03 at 5 37 51 PM

How can this be tested?

Prerequisites

A running MITxOnline instance with:

  • At least one live course with a product page
  • At least one live program with a product page
  • At least one program with display_mode="course" (program-as-course)

Steps

  1. Run the MITxOnline ETL to populate URLs:

    ./manage.py backpopulate_mitxonline_data
  2. Verify the summary API includes URLs:

    Visit: http://api.open.odl.local:8065/api/v1/learning_resources/summary/?platform=mitxonline&resource_type=course&resource_type=program&limit=1000

    Confirm that:

    • Each result includes a url field
    • Course URLs follow the format: {APP_BASE_URL}/courses/{readable_id}
    • Program URLs follow the format: {APP_BASE_URL}/programs/{readable_id}
    • Program-as-course URLs follow the format: {APP_BASE_URL}/courses/p/{readable_id}
  3. Verify the sitemap index includes products sitemap:

    Visit: http://open.odl.local:8062/sitemaps/sitemap-index.xml

    Confirm that it includes entries for /sitemaps/products/sitemap/{id}.xml

  4. Verify the products sitemap contains correct URLs:

    Visit: http://open.odl.local:8062/sitemaps/products/sitemap/0.xml

    Confirm that:

    • The sitemap contains entries for MITxOnline courses and programs
    • URLs point to Learn product pages (not MITxOnline)
  5. Verify noindex removal from product pages:

    Visit any product page and inspect the HTML <head>:

    • /courses/{readable_id}
    • /programs/{readable_id}
    • /courses/p/{readable_id}

    Confirm that <meta name="robots" content="noindex, nofollow"> is NOT present.

Additional Context

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

OpenAPI Changes

1 changes: 0 error, 0 warning, 1 info

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

Copy link
Copy Markdown
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zamanafzal This generally looks good to me. Left one very minor comment. Can do full review when out of draft.

Comment thread learning_resources/views.py Outdated
description="Get a paginated list of learning resources with summary fields",
description=(
"Get a paginated list of learning resources with summary fields "
"(id, last_modified, url). Includes ``url`` for sitemap and similar "
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there's much value in listing the fields here. The openAPI spec shows the response fields already.

@ChristopherChudzicki
Copy link
Copy Markdown
Contributor

@zamanafzal re the failing test... Seems flaky, but i suspect it's also removed (we changed that feature, i think) on main, if you want to rebase.

@zamanafzal zamanafzal force-pushed the zafzal/10755-seo-learn-product-pages branch 2 times, most recently from 38eeca2 to c9a479b Compare April 6, 2026 07:06
@zamanafzal zamanafzal force-pushed the zafzal/10755-seo-learn-product-pages branch from c9a479b to b249d41 Compare April 6, 2026 07:09
@zamanafzal zamanafzal marked this pull request as ready for review April 6, 2026 07:15
Copilot AI review requested due to automatic review settings April 6, 2026 07:15
Comment thread frontends/main/src/app/sitemaps/products/sitemap.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements SEO improvements for Learn product pages by exposing product-page URLs via the learning resources summary API and generating a dedicated products sitemap for MITxOnline courses/programs.

Changes:

  • Added url to the LearningResource summary API (serializer, view, OpenAPI spec, and generated client types).
  • Updated MITxOnline ETL to store Learn product-page URLs (courses, programs, and “program-as-course” URLs).
  • Added /sitemaps/products/sitemap/<id>.xml generation + tests, and included it in the sitemap index; removed explicit noindex, nofollow from product page metadata.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
openapi/specs/v1.yaml Documents new url field in LearningResourceSummary schema.
learning_resources/views.py Adds url to summary() queryset values output.
learning_resources/views_test.py Updates summary endpoint expectations and adds coverage for stored URLs.
learning_resources/serializers.py Includes url in LearningResourceSummarySerializer fields.
learning_resources/etl/mitxonline.py Writes Learn product-page URLs into LearningResource.url for MITxOnline resources.
learning_resources/etl/mitxonline_test.py Updates ETL transform expectations to reflect new URL behavior.
frontends/main/src/app/sitemaps/sitemap-index.xml/route.ts Adds products sitemap entries to the sitemap index.
frontends/main/src/app/sitemaps/products/sitemap.ts New dynamic products sitemap backed by summary API filtering for MITxOnline courses/programs.
frontends/main/src/app/sitemaps/products/sitemap.test.ts Tests sitemap index params and page generation/filtering behavior.
frontends/main/src/app/(products)/programs/[readable_id]/page.tsx Removes explicit robots: noindex, nofollow from program pages.
frontends/main/src/app/(products)/courses/p/[readable_id]/page.tsx Removes explicit robots: noindex, nofollow from program-as-course pages.
frontends/main/src/app/(products)/courses/[readable_id]/page.tsx Removes explicit robots: noindex, nofollow from course pages.
frontends/api/src/test-utils/factories/learningResources.ts Adds url to learning resource summary factory output.
frontends/api/src/generated/v1/api.ts Regenerates client types to include LearningResourceSummary.url.

Comment thread learning_resources/etl/mitxonline.py
Comment thread learning_resources/etl/mitxonline_test.py Outdated
Comment thread learning_resources/etl/mitxonline_test.py Outdated
Comment thread learning_resources/etl/mitxonline_test.py Outdated
Comment thread learning_resources/etl/mitxonline_test.py Outdated
@zamanafzal zamanafzal added the Needs Review An open Pull Request that is ready for review label Apr 6, 2026
Copy link
Copy Markdown
Member

@mbertrand mbertrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ETL changes look good to me, 👍

Copy link
Copy Markdown
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. 👍

@zamanafzal zamanafzal merged commit 83c58e3 into main Apr 6, 2026
14 checks passed
@zamanafzal zamanafzal deleted the zafzal/10755-seo-learn-product-pages branch April 6, 2026 14:24
This was referenced Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants