Adding the game to a Canvas page
-
Copy the classroom snippet
Copy the code below, or build your own on the embed generator and add &noguess=1 to the src address. Take both parts: the iframe and the one-line credit paragraph under it. Canvas keeps every attribute in this snippet when it saves the page.
-
Create a page: Pages > View All Pages > Add Page
In your course, click Pages in Course Navigation. If the course has a front page, click View All Pages first, then click Add Page and give the page a title. Any other item that uses the Rich Content Editor works too: an Assignment, a Discussion, an Announcement or a Quiz description.
-
Switch the Rich Content Editor to HTML view
Click the HTML Editor icon (the </> button at the bottom right of the editor, labelled "Switch to the HTML view"). Canvas opens the pretty HTML editor with line numbers. Click where the game should go and paste the snippet. If you prefer not to touch HTML, use Insert > Embed in the editor’s menu bar instead, paste the code into the Embed Code field and click Submit.
-
Switch back and check the preview
Click the HTML Editor icon again to return to the visual editor. The board should appear as a live preview inside the editor. If you see the iframe as a line of text instead, it was pasted into the visual editor rather than HTML view: undo, switch to HTML view and paste again.
-
Save & Publish, then view as a student
Click Save & Publish (or Save to keep it as an unpublished draft). Then open the page in Student View (the button on the course Settings page) and play a round to confirm the board loads, clicks register and the whole board fits.
The frame is blank: the admin's allowed domains
Canvas saves the iframe without complaint, so a blank rectangle on the published page is rarely an editor problem. Check these in order:
- Content Security Policy. A Canvas administrator can switch on the Content
Security Policy for the whole institution (Admin > the account > Settings >
Security). Once it is on, Canvas only lets pages frame domains on the Allowed Domains list,
plus Canvas's own and those of installed LTI tools. Ask your admin to add
play-minesweeper.gamesunder Domain Name and click Add Domain. Admins can also switch the policy off for a single course in its Settings, though most will prefer to add the domain. Teachers cannot change either setting. - School web filter. If the game also fails to open in a normal browser tab on the school network, the filter is blocking the domain, not Canvas. Our notes on playing Minesweeper at school cover what to ask IT for.
- An
http://address. Canvas is served over HTTPS and browsers refuse insecure frames inside it. The snippet useshttps://; keep it that way if you edit the URL.
To tell them apart, open the page, then open your browser's developer console. A message
mentioning "Content Security Policy" and frame-src means the allowed-domains
list; a filter usually shows its own block page inside the frame.
Where Canvas removes the iframe
Canvas cleans every Rich Content Editor field against its HTML allowlist when you save. The iframe passes in Pages, Assignments, Discussions, Announcements, Quizzes and the Syllabus. Two places behave differently:
- Calendar event descriptions drop any iframe that is not Canvas's own media or app launch. Put the game on a Page and link the Page from the event.
- Unsupported attributes are removed silently, for example
allow-top-navigationin asandboxvalue. The snippet uses none of them, so if you edited it and something stopped working, compare it with the original.
Choosing a size that fits the course layout
A Canvas page sits beside the global navigation and, when it is open, the course navigation menu, so the content column on a laptop is far narrower than the screen. The frame does not scale its board, so pick a size that fits the narrowest view your students use:
- Beginner 9×9 — 344 × 472 pixels. The snippet above. Fits beside both menus, in the Canvas Student app and on phones.
- Intermediate 16×16 — 536 ×
664 pixels. Fits a laptop; use it for older students. Change the src to
?size=intermediate&noguess=1and the width and height to match. - Expert 30×16 — 956 pixels wide. Wider than a Canvas content column on most laptops; link to the game instead.
Set the width and height in HTML view rather than by dragging the frame in the visual editor, so the numbers stay exact. If the board looks cropped at the bottom, the height is too small; if there is empty space under it, nothing is wrong.
Using it in class
The Minesweeper lesson for teachers is a 15-minute logic activity for exactly this board, with discussion prompts. A Canvas page works well for it: the board at the top, the rules students should find underneath, and a link to the printable Minesweeper worksheets for paper practice and homework. Add the page to the student to-do list from the page options if you want it on everyone's list for the lesson.