Instagram strip
The account's name, a follow link and a row of six square posts (three across on phones).
Show code
// src/content/settings/instagram.yaml (edited in Somnia CMS)
handle: headlandyachting
url: https://www.instagram.com/headlandyachting/
account: "17841451583197008" # optional: found from the token if left out
demo: true # library photos on staging until posts are fetched
// the site's build script, before astro build
"build": "somnia-tokens && somnia-instagram && astro build && somnia-pagefind"
// a page: the account's posts when there are any, else these (labelled as a demo)
<InstagramFeed posts={[{ src: photo1, alt: '…' }, …]} /> When to use it
- The business posts to Instagram often, and its pictures say something the site’s don’t.
- Near the foot of a home page or an About page.
Use something else when:
- The account is quiet: six old posts say the business has stopped.
- You only want a link to the account: the social icons in the footer.
- The pictures are the site’s own: a gallery.
Connecting a real feed
somnia-instagram fetches the account's newest six posts each time the site builds and saves their pictures with the site, so visitors' browsers never call Instagram and no cookies are set. It needs a professional (business or creator) account and a token from the site's own Meta app: create an app with the use case "Manage messaging & content on Instagram", add the account as an Instagram Tester, create a configuration (it can't go below instagram_basic and instagram_manage_messages; the script only ever reads posts) and generate the token. Keep it as the repository secret <SITE>_INSTAGRAM_TOKEN, never in a file. Real posts replace the page's own; until there are any, demo: true labels the strip as a mock-up and shows it on staging only. If Instagram doesn't answer, the build goes on with no posts.
How it works
- Each post links to the post (or the account) and opens in a new tab, which it says for screen readers.
- Kept out of site search.
- Alt text is the post's own, else the opening of its caption without hashtags or emoji.
Do and don't
Do
- Write alt text on Instagram when you post
- Keep the strip to one row of six
Don't
- Embed Instagram’s own widget, which loads its scripts and cookies
- Show a feed nobody is posting to
Accessibility
What it does for you
- A region named by its heading, a link to the account, then the posts as a list.
- Every post is a link named by its picture’s description, and says it opens Instagram in a new tab. A video says it is a video.
- A post’s description is the one written on Instagram; without one, the opening of its caption with the hashtags and emoji taken out.
- Posts are 100px squares or larger. A picture grows a little under the pointer, and not at all with reduced motion.
- The pictures are the site’s own copies: nothing loads from Instagram and no cookie is set.
What you need to do
- Write the alt text on Instagram when posting: it is what this shows.
- A heading that says what the strip is.
Keyboard
| Key | What it does |
|---|---|
| Tab | Moves to the account’s link, then each post in order. |
| Enter | Opens the post on Instagram, in a new tab. |
What a screen reader is told
- A region with the heading’s name; a list of six.
- Each post: a link, the picture’s description, then "(Instagram, opens in a new tab)".
This is what the browser reports to assistive technology. What each screen reader then says varies, and has not been listened to yet.
WCAG 2.2
| Criterion | Level | How this meets it |
|---|---|---|
| 1.1.1 Non-text Content | A | Every picture has a description. |
| 2.3.3 Animation from Interactions | AAA | The picture’s growth under the pointer switches off with reduced motion. |
| 2.4.4 Link Purpose (In Context) | A | Each link says what it shows and where it goes. |
| 2.5.8 Target Size (Minimum) | AA | Posts are at least 100px square; the account’s link is 24px high. |
| 3.2.2 On Input | A | A new tab is said before it opens. |
The criteria this component has a part in. A page that uses it still has to meet the rest.
Checked
| Check | How | Result |
|---|---|---|
| Automated (axe-core) | WCAG 2.0, 2.1 and 2.2 rules at A and AA, the page in light and in dark | Passed Nothing found, light or dark |
| Narrow screen | No sideways scrolling at 320px wide (WCAG 1.4.10) | Passed No sideways scrolling |
| Keyboard and what the browser reports | Real key presses on the live example, and the role, name and state given to assistive technology | Passed 9 of 9 checks pass |
| On paper | Somnia’s print check: no overlaps, stranded headings or controls on the page | Passed No faults on 5 sheets |
| Screen reader | Listened to by a person, in VoiceOver and NVDA | Not yet Not yet checked by a person |
The 9 checks made with the keyboard, on the example at the top of this page:
- Passed It is a region named by its heading, holding a list of six posts
- Passed Tab goes to the account’s link, then through the posts in order
- Passed Each post is a link named by its picture’s description, and says it opens Instagram in a new tab
- Passed A video says it is a video
- Passed The account’s link says it opens in a new tab
- Passed Keyboard focus on a post shows the 2px ring, outside the picture
- Passed Posts are at least 44px square
- Passed With reduced motion a picture doesn’t grow under the pointer
- Passed Every picture comes from this site
Run by script on against Somnia DS 1.89.0, in Chromium with axe-core 4.14.0. How these checks work, and every component's results.
Not yet checked
- How it sounds in a screen reader (VoiceOver, NVDA, TalkBack) has not been checked by a person. The roles, names and states the browser reports are checked by script; what is actually spoken is not.
- Windows high contrast (forced colours) has not been looked at by a person.
- Descriptions made from a caption are a stand-in: they say what the post says, not what the picture shows. Nobody has gone through a real feed’s.
- People looking at the screen aren’t told a post opens a new tab: the words are for screen readers only.
Evidence
Where it's used
| Where | For |
|---|---|
| Headland Yachting | The home page, with the account’s newest six posts fetched each time the site builds. |
What we saw, and what changed
| When | What we saw | What changed |
|---|---|---|
| The strip’s pictures are links, and looked like any other picture. | Pictures in links grow a little under the pointer, by one shared token (1.22.1). | |
| The strip showed library photos standing in for posts. | Real posts: the newest six are fetched when the site builds and their pictures kept with the site (1.76.0). |
From building and using it on real sites, each entry taken from the changelog or the build's own notes. This is observation by the studio and its clients, not research sessions with users.
What we don't know yet
- How many people follow a post to Instagram is not counted.