Skip to product information
1 of 1
Published:2026.05.02

[Horizon] Add a Back to Top Block to Your Footer

[Horizon] Add a Back to Top Block to Your Footer

Applications

  • ナビゲーション管理・編集
View full details

Add a "Back to top" floating button to your Horizon footer as a theme editor block. It's implemented as a private block scoped to the footer section, so it won't appear in other sections' add-block menus. Color, size, icon thickness, shadow, position, and shape are all configurable from the theme editor.

Floating Back to Top button

How it works

You add a new private block blocks/_back-to-top.liquid and register it in the footer section's (sections/footer.liquid) blocks array, which makes it appear in the theme editor's "Add Block" menu. Private blocks (filename prefixed with _) are scoped to the footer only, so they don't appear in other sections.

The footer's .footer-content has contain: content, which makes any position: fixed descendants positioned relative to .footer-content instead of the viewport. To work around this, the block's JavaScript moves the button to document.body on initialization, restoring viewport-relative positioning.

Files to add or modify

File path Action
blocks/_back-to-top.liquid Create new file (248 lines)
sections/footer.liquid Add 3 lines at L105–L107 (in the blocks array)
locales/ja.schema.json Add keys to names / settings / content sections
locales/en.default.schema.json Add keys to names / settings / content sections

Line numbers are based on the vanilla Horizon theme (v3.5.1).

Steps

  1. Shopify admin → Themes → Edit code
  2. Create _back-to-top.liquid in the blocks/ folder and paste the downloaded code
  3. Open sections/footer.liquid and add {"type": "_back-to-top"} to the blocks array in the schema
  4. Add the translation keys to locales/ja.schema.json and locales/en.default.schema.json
  5. Open the theme editor, go to the footer section, click "Add block" → "Back to top"
  6. Customize color, size, icon thickness, shadow, position, and shape
Theme editor showing Back to Top block

File to add: blocks/_back-to-top.liquid

Paste the entire code as a new file. The first half is the template/style/script, and the second half is the schema definition.

_back-to-top.liquid first half _back-to-top.liquid second half

File to modify: sections/footer.liquid

Add _back-to-top to the blocks array in the schema, between @app and button (lines L105–L107).

sections/footer.liquid modification

Files to modify: locales/ja.schema.json / locales/en.default.schema.json

Add the same translation keys to both locale files so the theme editor labels are localized correctly. Three sections need updating: names, settings, and content.

Translation keys to add

Block settings

Section Setting Range / Default
ColorButton background#EEEEEE
Icon color#000000
SizeButton size30–100px / 60
Icon size10–50px / 30 (independent of button size)
Icon thickness1–10px / 6
ShadowShadow color#000000
Shadow opacity0–100% / 15
Shadow blur0–30px / 8
Shadow vertical offset0–20px / 2
BehaviorShow after scrolling0–1000px / 100
LayoutPositionBottom right / Bottom left
ShapeCircle / Square

Notes

  • Private block (filename starts with _): The file must be named _back-to-top.liquid. Without the leading underscore, the type reference {"type": "_back-to-top"} in sections/footer.liquid won't match.
  • All four files must be modified: The block file alone won't work. You need to register it in footer.liquid and add the translation keys to both locale files.
  • Theme update impact: If sections/footer.liquid or locales/*.schema.json are updated by future Horizon releases, you'll need to re-apply your additions.
  • vector-effect: non-scaling-stroke: This SVG attribute makes the stroke width independent of the icon size. So even at icon_size 20px, a thickness of 1px renders as 1 actual pixel.
  • JS teleports the button to document.body: Because .footer-content has contain: content, position: fixed would normally be relative to the footer instead of the viewport. The script moves the button out to escape this containment.

After making a purchase (all items are ¥0), you will be able to view the sample code.

If you have already made a purchase, please login here.

Sample Codes

Test Theme :Horizon 3.5.1

blocks/_back-to-top.liquid(新規作成)