Adding an edit button to my static site on mobile


In my My static site editing bookmarklet blog post, I outlined the bookmarklet I made that, when clicked, automatically takes me to the GitHub page associated with a URL on my website. I use this link daily to edit the wiki-like pages on this website.

Today, I thought to myself: what would it look like to have an edit button on mobile?

I have not edited many pages on my site from mobile, but I would like to explore making small changes to the wiki-like pages on my website (i.e. my movies list) from my phone.

There was no easy way for me to edit a page before I started this project. Going to the GitHub app – which I can use to edit my site on my phone – and manually opening folders is a lot to make an edit, especially when I can go to Notion, the note-taking app I use, and write down an idea with a few taps or a swipe. In such a workflow, I can add the note to my site later. Also, mobile editing experiences, generally, are not great. I think there is so much room to make things related to editing on mobile!

I am hoping this project empowers me to edit more pages on my website while I am on the go. I don’t typically write blog posts on my phone – it is tricky to type long prose. But adding a note to a list or adding a relevant link I found to a wiki page? These are appealing use cases!

I wanted an edit button that, when clicked, would let me edit a blog post. The button should be easy to press on mobile devices.

I had a few requirements:

  1. The edit button should directly open the GitHub iOS app, from which I can edit the page I am viewing. My website is static. I use GitHub to build the site.
  2. The button should only show up if an “editing mode” is enabled.

Due to limitations in WebKit, the iOS browser engine, I could not use a bookmarklet. With this in mind, I decided to create a script that would make an edit button appear on a page if a cookie is set. I will be the main user of this feature and so the button doesn’t need to show up unless enabled.

Here is what the edit button looks like:

A blog post on my website with a white button in the bottom right corner that shows a pencil icon

When clicked, the button opens the GitHub app at the page I was viewing:

The source file for the blog post I was viewing, now opened in the GitHub app from which I can open the file editor and make changes

I can then open the file menu in the GitHub app and click edit.

On every page, a script loads that checks for a cookie. The cookie is only set if you visit a specific page on my website. This lets me enable the editing mode on my device without surfacing a page that people can click. This is important because my repository is private and so the editing mode would open broken links for anyone other than me (because I am signed into the GitHub app as me).

If the cookie is set, an edit button is added to the bottom of the page. The href of this edit button is determined by similar code to what I wrote for my desktop editing bookmarklet. The script sets the href depending on whether the page is a post or a wiki-like page. Posts have the URL path /YYYY/MM/DD/slug whereas wiki-like pages use the pattern /.

The final URL uses the github:// app handler to open a link. Here is an example for a wiki page:

github://github.com/capjamesg/jamesg.blog/tree/main/pages/templates/wiki/movies.html

When clicked, iOS opens the link in the GitHub application. The link opens directly to the file that I can then edit.

If I am on a 404 page, my app opens to the pages/templates/wiki folder so I can create a new file. The GitHub URL path to directly create a new file – with front matter pre-configured! – that I use in my desktop bookmarklet doesn’t work with the app handler. This means I will need to author the front matter . Or will need to have a page somewhere that stores the default front matter that I usually use so I can paste it in when making a new page. Or make a web page to generate the front matter for me that I can copy.

With this approach, I have an edit button that:

  1. Automatically takes me to a file that I can edit if the file exists.
  2. Takes me to my wiki folder in GitHub if I am viewing a page that doesn’t exist so I can create it.
  3. Only shows up if a cookie is set, so readers don’t run into the button while exploring the site.

One downside to this implementation is that I need the edit button code to load on every page. It is not ideal to load code that nobody but me will use. With that said, I am keeping the code as lightweight as possible. I load the code at the end of a page. This ensures the JavaScript loading process does not block other parts of the page. I do the same with the code that makes my seasonal emojis work, too.

You can view the source code for this project on GitHub. You can make the script work on your site by replacing the repository name and paths with those you use on your website.

If you have any ideas on how this script can be improved, please let me know! My next step is to add a feature to exit editing mode.

Also posted on IndieNews



Source link

Visited 1 times, 1 visit(s) today

Related Article

Nvidia’s trillion-dollar run puts pressure on the bulls

BEIJING, CHINA – MAY 14: Nvidia CEO Jensen Huang (C) gestures as he prepares to depart following a welcome ceremony at the Great Hall of the People on May 14, 2026 in Beijing, China. President Trump is meeting with President Xi Jinping in Beijing to address the Iran conflict, trade imbalances, and the Taiwan situation

Permutations in Europe: What’s still at stake in final weeks of season?

There’s still plenty to play for across Europe as we head into the final matches of the club season. Here are all the title races, Champions League fights, and relegation battles left to be decided in the top leagues this month. This story will be updated until the end of the campaign. 👉 Jump to:EPL

Brewing a Better Half-Gallon Batch

Today I finally ran an experiment I’ve wanted to try for a long time. If you’re a professional barista—or you run a busy café—this may save you some time. Most coffee shops use 1–1.5 gallon batch brewers (Bunn, Curtis, Fetco, etc.). When I opened Short Sleeves Coffee, I intentionally avoided brewing full 1-gallon batches. I

5 Frozen Breakfasts Chefs Say Keep You Full All Morning

Chef-approved frozen breakfasts with more protein and better ingredients. Eating a healthy breakfast every morning is a great way to start the day, but most people don’t have time to cook. Whether you’re rushing out the door in the morning for work, taking the kids to school or both, there’s usually not much time in

CA scales back plan to ban student use of cell phones

By Carolyn Jones, CalMatters This story was originally published by CalMatters. Sign up for their newsletters. Until last month, California was poised to join nearly a dozen other states that ban cell phones in K-12 schools. But under pressure from school boards and administrators, lawmakers scaled back a bill that would have required such a

BulkQuant Launches AI Trading Bot for Crypto, Forex, and Stock Markets

BulkQuant Launches AI Trading Bot for Crypto, Forex, and Stock Markets

London, United Kingdom, May 15, 2026 (GLOBE NEWSWIRE) — BulkQuant has officially launched its AI trading bot platform designed for crypto, forex, and stock market traders seeking a simpler way to automate trading strategies across multiple financial markets. The platform combines AI-powered quantitative analysis, automated trade execution, portfolio monitoring, and adaptive risk management into a

IMF lauds resilient Hong Kong economy but warns of risks linked to Middle East war

IMF lauds resilient Hong Kong economy but warns of risks linked to Middle East war

The International Monetary Fund (IMF) has lauded the resilience of Hong Kong’s economy, noting a sustained recovery despite economic activity having yet to return to pre-Covid levels, while warning of downside risks stemming from escalating geopolitical tensions. It also urged Hong Kong to pursue medium-term financial reforms, including the introduction of a goods and services

Smithsonian Presidents Exhibit Reopens With Low-Key Trump Impeachment Mention

For the past year, the Smithsonian Institution has found itself in the awkward position of telling the nation’s story while being supported in part by a government that wants to narrow how that story is told. In December, the White House threatened to revoke funding to the institution if it did not hand over a

Marvel’s Daredevil Follow-up Is Already Dominating on Streaming

A follow-up to Daredevil: Born Again Season 2 on Disney+ has become a massive streaming success within days of its launch. The Punisher: One Last Kill has quickly climbed to the top of multiple charts, beating out other titles on the platform. The MCU television special follows the gun-toting vigilante, who finds himself targeted by

Is Now a Bad Time to Invest?

The market has been on a roll lately, with the S&P 500 (SNPINDEX: ^GSPC) setting new highs throughout May. If you think you missed your opportunity when the market bottomed in late March, don’t fret. The market hitting new all-time highs is not particularly rare and should not change your investment strategy. And if you

6 bids for Hong Kong land sale signal renewed confidence despite market caution

6 bids for Hong Kong land sale signal renewed confidence despite market caution

The Hong Kong government’s first land sale in the current financial year has drawn six bids, according to the Development Bureau, including those from the city’s largest developers, suggesting a more confident outlook for the residential property market. At the close of tender for Tung Chung Town Lot No 54 at Area 106A on Friday

Each Premier League team reranked: Man City rise; Chelsea, Liverpool collapse

Ryan O’Hanlon Close Ryan O’Hanlon ESPN.com writer Ryan O’Hanlon is a staff writer for ESPN.com. He’s also the author of “Net Gains: Inside the Beautiful Game’s Analytics Revolution.”  and  Bill Connelly Close Bill Connelly ESPN Staff Writer Bill Connelly is a writer for ESPN. He covers college football, soccer and tennis. He has been at

Trump departs China after two-day summit

Trump departs China after two-day summit

IE 11 is not supported. For an optimal experience visit our site on another browser. Trump Wraps China Summit With Xi Jinping: What Are the Results? 05:41 Xi gives Trump rare tour of secret garden at heart of Chinese government 01:04 Now Playing Trump departs China after two-day summit 01:01 UP NEXT Special Report: Trump

Carol Chow was facing a bankruptcy petition by five people over unspecified debts at the time of her death. Photo: Dickson Lee

Embattled Hong Kong developer sued for HK$130 million, days after founder’s death

A Hong Kong property developer has been sued for HK$130 million (US$16.6 million) over allegedly breaching guarantor obligations in two bond subscription agreements, becoming the latest lawsuit to implicate the embattled company and following its founder’s sudden death earlier this week. Lofter Group, known for its urban renewal projects across the city’s core districts, and

Trump’s China visit left chip export issue unresolved

This report is from this week’s The Tech Download newsletter. Like what you see? You can subscribe here. One look at the roster of U.S. execs that cozied up to U.S. President Donald Trump on the 20+ hours flight from Alaska to China on Wednesday and you get a sense of the American delegation’s key focus

Why the Cerebras IPO matters for the AI race with China

Why the Cerebras IPO matters for the AI race with China

Cerebras, an AI chipmaker, saw its shares nearly double on Nasdaq, closing up 70% with a $95B market cap. Cerebras’s powerful chips are key in the US-China AI tech race. Chris Buskirk, co-founder and chief investment officer of 1789 Capital, a key Cerebras investor, says the company’s IPO is geopolitically significant. On Thursday, shares of

Fitbit Air vs Whoop Strap Comparison: Price, Features and AI

The Google Fitbit Air is very much the talk of the fitness tracking town right now, not only because it’s the first new Fitbit device that we’ve had in years, but it’s also one of the first big brands to go head-to-head with the established Whoop Strap (if you don’t count the Polar Loop and

0
Would love your thoughts, please comment.x
()
x