看得透又看得远者prevail. ppt.cc/flUmLx ppt.cc/fqtgqx ppt.cc/fZsXUx ppt.cc/fhWnZx ppt.cc/fnrkVx ppt.cc/f2CBVx
t.ly/s0R4x t.ly/gDGm6 ppt.cc/fwlgFx ppt.cc/fVjECx ppt.cc/fEnHsx ppt.cc/fRZTnx ppt.cc/fSZ3cx ppt.cc/fLOuCx ppt.cc/fE9Nux ppt.cc/fL5Kyx ppt.cc/f71Yqx tecmint.com linuxcool.com linux.die.net linux.it.net.cn ostechnix.com unix.com ubuntugeek.com runoob.com man.linuxde.net ppt.cc/fwpCex ppt.cc/fxcLIx ppt.cc/foX6Ux linuxprobe.com linuxtechi.com howtoforge.com linuxstory.org systutorials.com ghacks.net linuxopsys.com ppt.cc/ffAGfx ppt.cc/fJbezx ppt.cc/fNIQDx ppt.cc/fCSllx ppt.cc/fybDVx ppt.cc/fIMQxx
Total Pageviews
Friday, 27 November 2026
让instinct帮我搭建基于vuejs+github issues的静态博客程序bib
Wednesday, 18 November 2026
How to use GitHub as a Real-Time Headless CMS for Astro
I have been blogging since 2011. Back then, WordPress was the king of the hill. But it is 2026 now and the web has changed. I am tired of the endless cycle of plugin updates, heavy PHP backends, and cluttered themes. Even in my coding life, I have moved away from heavy frameworks like Django in favor of FastAPI.
When I decided to restart my blog as a hobby to save my thoughts, I knew I wanted something fast and modern. Astro is the perfect fit because of its minimal JS footprint. While Astro allows you to keep markdown files in your local source folder, that can make your main build heavy over time.
Instead, I decided to use GitHub as my Headless CMS using true SSR (Server Side Rendering). This means I build the site once and it fetches the latest content from a separate GitHub repository whenever a user visits the page. No more redeploying just to fix a typo.
The Game Plan
Traditionally, you have to define every blog post detail in a local config file. If one piece of frontmatter is missing, the whole project might break. We are going to avoid that by using Octokit, the official GitHub SDK, to pull our data dynamically.
Step 1: Configure Astro for SSR
Before we write any logic, we have to tell Astro to run on a server rather than building static files. Open your astro.config.mjs and update it to enable server output and prefetching.
import { defineConfig } from 'astro/config';
export default defineConfig({
output: 'server',
prefetch: {
prefetchAll: true
},
});
Step 2: Set Up Your Content Vault
Create a new GitHub repository to act as your Content Vault. You can organize it however you want. I prefer keeping things chronological using a folder structure like: {blog\_name}/{YYYYMM}/{blog-post.md}.
Step 3: Frontmatter Specification
Every .md or .mdx file in your repository must include a YAML block at the top. This is critical because the SSR loader needs these details to build your UI without breaking.
---
title: "The Title of Your Post"
date: 2025-12-24
description: "A short, 2-sentence hook for the blog archive list."
featured_img: "[https://images.pexels.com/photos/7005491/pexels-photo-7005491.jpeg](https://images.pexels.com/photos/7005491/pexels-photo-7005491.jpeg)"
tags: ["Health", "Systems", "Curiosity"]
---
Step 4: Secure Your Connection
To let your Astro site talk to GitHub, you need a Personal Access Token:
Go to GitHub Settings > Developer Settings.
Select Personal Access Tokens and then Tokens (classic).
Generate a new token with
repopermissions and set it to No Expiration.Copy that token and paste it into your Astro project
.envfile asGITHUB\_TOKEN.
Step 5: The Octokit Service
We use Octokit, the official GitHub SDK, to pull data. Create a file at src/lib/octokit.ts. This script will handle fetching the list of posts and the individual content.
In this file, we initialize Octokit with your token. The getPosts function scans your folders, filters for markdown files, and even calculates a reading time automatically by counting words and dividing by an average speed of 200 words per minute.
import { Octokit } from "octokit";
import matter from "gray-matter";
export const octokit = new Octokit({
auth: import.meta.env.GITHUB_TOKEN,
});
const REPO_DETAILS = {
owner: "your-github-username",
repo: "your-repo-name",
};
export const PostService = {
async getPosts(space: string) {
try {
const { data: dateFolders } = await octokit.rest.repos.getContent({
...REPO_DETAILS,
path: space,
});
if (!Array.isArray(dateFolders)) return [];
const postGroups = await Promise.all(
dateFolders.filter(f => f.type === "dir").map(async (folder) => {
const { data: files } = await octokit.rest.repos.getContent({
...REPO_DETAILS,
path: folder.path,
});
if (!Array.isArray(files)) return [];
const contentFiles = files.filter(f =>
f.name.toLowerCase().endsWith('.md') ||
f.name.toLowerCase().endsWith('.mdx')
);
return Promise.all(contentFiles.map(async (file) => {
const { data: rawContent } = await octokit.rest.repos.getContent({
...REPO_DETAILS,
path: file.path,
headers: { 'accept': 'application/vnd.github.v3.raw' }
});
const { data: frontmatter, content } = matter(rawContent as string);
const wordCount = content.split(/\s+/).length;
const readingTime = Math.ceil(wordCount / 200);
const slug = file.name.replace(/\.mdx?$/, "");
return {
id: slug,
folderDate: folder.name,
fullPath: file.path,
readingTime,
...frontmatter
};
}));
})
);
const allPosts = postGroups.flat();
return allPosts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
} catch (error) {
console.error("GitHub Fetch Error:", error);
return [];
}
},
async getPostContentBySlug(space: string, slug: string) {
const allPosts = await this.getPosts(space);
const post = allPosts.find(p => p.id === slug);
if (!post || !post.fullPath) return null;
const { data } = await octokit.rest.repos.getContent({
...REPO_DETAILS,
path: post.fullPath,
headers: { 'accept': 'application/vnd.github.v3.raw' }
});
return data;
}
};
Step 6: Displaying the List
In your index.astro file, you can now pull your list of posts. Since we are using SSR, this list is always fresh. You just call the getPosts function, sort them by date, and map them into your UI components.
---
import { PostService } from '@/lib/octokit';
const posts = await PostService.getPosts('travel');
---
<div class="grid grid-cols-1 md:grid-cols-2 gap-12">
{posts.map((post) => (
<div class="card">
<a href={`/blog/${post.id}`}>{post.title}</a>
<p>{post.description}</p>
</div>
))}
</div>
Step 7: The Single Post Page
Create a dynamic route at src/pages/blog/\[id\].astro. By setting "export const prerender = false", you tell Astro to fetch the content from GitHub every time someone visits the URL. We use the "matter" library to parse the frontmatter and "marked" to turn the raw markdown into HTML.
---
import { PostService } from '@/lib/octokit.ts';
import matter from 'gray-matter';
import { marked } from 'marked';
export const prerender = false;
const { id } = Astro.params;
if (!id) return Astro.redirect('/404');
const rawMarkdown = await PostService.getPostContentBySlug('travel', id);
if (!rawMarkdown) return Astro.redirect('/404');
const { data, content } = matter(rawMarkdown as string);
const htmlContent = marked.parse(content);
---
<article>
<h1>{data.title}</h1>
<div set:html={htmlContent} />
</article>
A Word on Traffic and Limits
It is important to note that if you expect 1,000 visitors at once, you might hit the GitHub API rate limits. If your blog reaches that level of scale, it is better to move your content vault away from GitHub to a dedicated database. However, since my personal blogs do not see massive spikes and my content is centrally located, I am currently very happy with GitHub. It is free, version-controlled, and reliable for my needs.
If you want I can send the open source code for this sample Astro and Headless GitHub CMS setup below. Reach me on X @ CodingFromMars.
from https://web.archive.org/web/20260213170213/https://www.theonlyanil.com/dev/blog/how-to-use-github-headless-cms-astrojs
Monday, 16 November 2026
Thursday, 5 November 2026
让muse帮我在cloudflare.com平台构建基于astro+github issues的静态博客程序bcb
me: can u build https://github.com/brightmann/bcb?
On bcb: it's an Astro static blog (114 posts, content baked in as committed data), so it fits Workers as a static site. Plan is bcb.luckypoem.workers.dev serving the built output. The AI chat and GitHub login parts need a live backend server with Postgres, Redis, and a DeepSeek key, so those stay out of this build unless you ask for them separately. Install is running now; I'll build and deploy next.
Bcb's build succeeded but the deploy failed on one missing flag — Wrangler now requires a compatibility date. I've told it to retry with that flag added and to verify the homepage and an article page after.
Bcb is live: https://bcb.luckypoem.workers.dev/
Verified myself just now — homepage and the article page both return 200 with real content. Pushes to the repo rebuild it automatically. The AI chat and login server aren't part of this; the blog reads fine without them, but the chat widget will fail if opened until a backend is hosted.
我: can u create a source post about bcb.luckypoem.workers.dev?
Quick check before I create it in the wrong place: bcb's posts don't come from brightmann/bcb. All 114 live posts are GitHub Issues from bosens-China/blog, which isn't yours, so its normal pipeline can't put a post of yours on the bcb blog itself.
me: i also create a issue here https://github.com/brightmann/bcb/issues/1, why the issue isn't converted into a post of bcb.luckypoem.workers.dev?
First, a correction to what I told you before: the pipeline reads whichever repo it runs in, so on brightmann/bcb it would read your issues (filtered to your own). The 114 live posts are bosens-China/blog's only because that data came along with the fork from the author's runs.
So why isn't issue #1 a post: brightmann/bcb is a fork, and GitHub disables Actions on forks until the owner turns them on. Your issue event never ran the pipeline at all — no run, no regenerated data, no data push, and the Workers site only rebuilds on a push. That's the whole break.
Once you enable it, the rest of the chain works without extra keys: the LLM stages just skip without a key, image uploads fail softly, and the final DogeCloud deploy step (which would fail without DogeCloud secrets) runs after the data commit and push, so it doesn't block the workers.dev copy.
Your step: open brightmann/bcb → Actions tab → click "I understand my workflows, go ahead and enable them". Then editing issue #1, or manually dispatching the Deploy Blog workflow, will trigger a run — tell me once you've enabled it and I'll watch for the data push and the rebuild.
me: i have enabled github actions.
No run has fired yet — I checked, 0 runs and the repo is unchanged. That's expected: issue #1 was created before you enabled Actions, so its event won't retroactively trigger anything.
One thing to confirm before you trigger it: the first successful run replaces all 114 posts with only your own issues — right now just #1. The site becomes yours-only, not the 114 plus yours. Is that what you want?
If yes, trigger it by editing issue #1 (any small edit) or by running the Deploy Blog workflow manually from the Actions tab, and I'll watch for the data push and the rebuild.
What's missing isn't enablement, it's indexing: GitHub lists zero workflows even though both files are on the default branch (I verified via the API and the clone). The files arrived with the fork rather than via a push, so no indexing event ever fired, and enabling Actions doesn't retroactively index them.
Fix: push any commit to new-blog@v1. Easiest path without involving me: edit any file under apps/blog/ in GitHub's web UI and save. That one push both makes the workflows appear and triggers the Deploy Blog run (apps/blog/ matches its paths filter), and then the data push → rebuild chain should carry issue #1 to the site.
me: i just edited https://github.com/brightmann/bcb/blob/new-blog%40v1/apps/blog/package.json 3 min ago. but i didn;t see https://bcb.luckypoem.workers.dev/ updated.
That's expected at this point, for two separate reasons:
Your push did trigger a Workers rebuild, but it rebuilds from the unchanged data — still the 114 posts, no issue #1 in it. So the site comes back looking identical.
The run that would actually add issue #1 never started: 0 Actions runs. The push that made the workflows appear didn't itself trigger a run — the indexing and the trigger raced, and the trigger lost.
So one more trigger is needed now that the workflows are listed: edit issue #1, or dispatch Deploy Blog manually from the Actions tab. That run regenerates the data (replacing the 114 with just your issues, as flagged), pushes it, and the Workers rebuild after that is the one that shows #1. Say the word and I'll dispatch it from here instead.
我: i say the word
Dispatching it now — I'll report the run status when it comes back, then watch for the data push and the rebuild.
Dispatch didn't happen — and I need to correct what I told you before. My "it's enabled, the missing banner proves it" was wrong: the main Actions list page doesn't show the banner, but the Deploy Blog workflow page does. It still says "Workflows aren't being run on this forked repository," with no Run control — only the "I understand my workflows, go ahead and enable them" button.
So whatever you enabled earlier wasn't that gate. Discovery and running are separate: your push got the workflows listed, but runs are still blocked until the fork owner clicks that button.
Nothing was changed and no run was created. One click left on your side: open the Deploy Blog workflow page and hit "I understand my workflows, go ahead and enable them" — then say the word again and I'll dispatch it immediately.
me: https://github.com/brightmann/bcb/actions/runs/41397886193 failed. how to fix it?
Found the failing step: it's "Check Astro Frontend" — everything before it passed, including data generation. Because that check failed, the build, data commit, and deploy steps were all skipped, which is why nothing changed.
Two things already ruled out: your package.json edit was just 3 blank lines, so it didn't break anything, and the job log itself needs admin rights, so I can't read it directly. I'm reproducing the same check locally right now to get the exact error.
Local check passes with the old data (0 errors), so the runner's failure is data-dependent — it's something about the regenerated data, not the code or your edit.
Two facts about that regenerated data: there's no brightmann/brightmann profile repo, so the About content comes back empty, and issue #1 is a 24-character test post. I'm regenerating that same data locally now to reproduce the exact check error.
Found it, and it's not your edit or the data. The run failed at "Check Astro Frontend" with a config "Invalid URL" error, and I reproduced it locally.
Cause: the fork has no DOGECLOUD_STATIC_DOMAIN variable, so the workflow passes it to the check step as an empty string, and the Astro config ends up with site: '' — an invalid URL. I isolated it: only that one variable breaks it. Empty values for the other two pass fine, and your package.json edit was just 3 blank lines.
Fix: set one repository variable — in brightmann/bcb, Settings → Secrets and variables → Actions → Variables, add DOGECLOUD_STATIC_DOMAIN = https://bcb.luckypoem.workers.dev. Then re-run the workflow.
One heads-up: the run's final DogeCloud deploy step will still fail without DogeCloud secrets, but it runs after the data commit and push, so your post still lands on workers.dev despite the red X at the end. Say the word and I'll set the variable and re-run it from here.
me: here https://github.com/settings/profile/ ,i didn't see 'Secrets and variables'.
Wrong page — that's your user profile settings. Repository variables live in the repo's own settings, not your account settings.
Go here: brightmann/bcb → Settings → Secrets and variables → Actions
Then click the Variables tab (not Secrets), New repository variable, name DOGECLOUD_STATIC_DOMAIN, value https://bcb.luckypoem.workers.dev, and save.
me: https://github.com/brightmann/bcb/actions/runs/41399428017 still failed.
me: ok, you re-run the workflow.
Before the re-run: the last run actually worked where it matters, and re-running it won't help. Here's the full picture:
That run's Check, Build, and data commit all passed — the data commit landed with only your post (测试). Only the final DogeCloud step failed, which is irrelevant for workers.dev.
But the post still isn't live for a different reason: Workers Builds skipped the build for that data commit, because its message contains "[skip ci]". Your package.json push (no marker) triggered a build; the bot's data push (marker) got skipped. That's why the homepage still shows the old 114 posts and /articles/1/ still 404s.
A workflow re-run would regenerate identical data, find no changes, push nothing, and trigger no build — so it changes nothing.
The actual fix is one push without [skip ci]: that triggers a Builds run from the current data, and your post goes live a few minutes later. Fastest way is another trivial web edit from you (like the package.json one). Or paste a bcb PAT and I'll push one — which way?
me: issue#1 contains "[skip ci]"?
No — your issue #1 doesn't contain it at all. It's titled "测试" with a short body, no "[skip ci]" anywhere in it.
The "[skip ci]" is in the bot's data commit message: after the pipeline ran, it committed the regenerated data as "chore: update blog data cache [skip ci]". That's the workflow's own hardcoded message, not anything from your issue. Workers Builds saw that message on the commit and skipped building — which is why your post, despite being in the data, never reached the live site.
me: bcb's PAT here...
Pushed — commit 0549490 "chore: trigger Workers Builds rebuild", no skip marker in the message, and the remote is clean (nothing stored). That PAT is safe to revoke now; it was used only for this one push.
The rebuild should be running from it. I'll verify issue #1 live in a few minutes once it finishes.
It's live. The rebuild succeeded, the homepage now shows only your post, and https://bcb.luckypoem.workers.dev/articles/1/ returns 200 with "测试".
me: u said 'The "[skip ci]" is in the bot's data commit message', where is the bot's data commit message?
Two places, same text:
- The commit itself: github.com/brightmann/bcb/commit/6d88a0d — made by github-actions[bot], message "chore: update blog data cache [skip ci]".
- Where that message comes from:
.github/workflows/deploy.yml, line 110, in the "Commit and Push Changes" step:git commit -m "chore: update blog data cache [skip ci]" --no-verify.
So it's hardcoded in the author's workflow template — your issue content never touches it.
me: why u don't delete [skip ci] from that line 110?
Fair question — I held off because it's a permanent change to the author's file with a side effect, not because it can't be done. I just verified the side effect, and it's small:
If I delete [skip ci] from line 110, the loop becomes fully automatic: new issue → pipeline → data push → Builds rebuilds, no manual trigger commit needed. The cost is one extra Actions run per data push, because the push paths include packages/blog-data/** — but it stops there, no infinite loop: the commit step only pushes when data actually changed (if [ -n "$(git status --porcelain packages/blog-data)" ]), so the extra run finds nothing and ends. The run will still show red at the last DogeCloud step (missing secrets), same as now — cosmetic for workers.dev.
The other reason I didn't just do it: pushing a workflow file needs a PAT with Contents + Workflows scope, and I don't know if the one you pasted has that (plus I already told you it's revocable, so it may be gone).
Want me to delete it? If so, paste a PAT with Contents + Workflows for bcb and I'll push the one-line edit — or you can delete [skip ci] from line 110 in the web editor yourself, which needs no token at all.
me: if i don't delete [skip ci] from line 110, and i published second issue, my blog won't be updated?
Yes, that's right — not automatically. Here's the chain for issue #2 with line 110 unchanged:
You publish issue #2 → the workflow runs → it regenerates the data (now issues #1 and #2) → it commits that data with the same "[skip ci]" message → Workers Builds skips that push → the live site stays on issue #1 only.
The data in the repo would be correct, but the site wouldn't rebuild. Each new issue would need the same manual workaround as this time: one extra push without "[skip ci]" to trigger the build. Deleting it from line 110 is what makes new issues go live on their own.
me: i deleted it. need to wait 2 min to let the new post go live?
No wait needed for the current post — issue #1 is already live, I just re-checked (homepage 200, showing 测试).
And your deletion is confirmed: origin's line 110 now reads git commit -m "chore: update blog data cache", no [skip ci]. That edit push triggered a Builds rebuild that's still running, but it deploys the same content (only issue #1), so nothing new will appear from it.
For a future second issue, though, 2 minutes is too short: the pipeline run plus the Builds rebuild take roughly 5–10 minutes total from publishing to live. One heads-up: the Actions run on your edit shows failed, but that's just the DogeCloud step again — it doesn't affect workers.dev.
me: https://bcb.luckypoem.workers.dev/articles/2 show nothing.
me: now it's ok. i wait about 4 min.
Confirmed — /articles/2/ is live with "一位老兄的人生告诫". And that 4-minute wait makes sense:
Issue #2's own data push (00:19) still carried [skip ci], because it ran before your deletion — so Builds skipped it. Your deletion push (00:25) triggered the rebuild that picked up both posts, and that rebuild took the ~4 minutes you waited.
From the next issue on, no trigger is needed: data pushes no longer carry [skip ci], so they build directly. Still allow ~5–10 minutes total for the pipeline plus the build.
me: can u make https://bcb.luckypoem.workers.dev/ support pagination?
On it — adding pagination to bcb in your usual shape: 5 per page, numbered pager, hidden when there's a single page. With 2 posts right now the pager won't show until a 6th post lands, but the mechanism will be in place.
I'm verifying the build locally first. Once it checks out, I'll need a fresh bcb PAT to push it live.
Pagination's done and verified locally: build green, type check clean, page 1 shows the 5 newest, page 2 shows 测试, pager on both pages. It's committed locally as ac61f2f, nothing pushed yet.
Two notes: the homepage "全部文章" link was removed since the pager now does that job (revertible if you want it back), and /page/1 isn't generated — it 404s rather than redirecting to /. Also, the site's grown to 6 posts since, so the pager will show immediately once this deploys — 2 pages, not hidden.
Paste a fresh bcb PAT and I'll push it live.
me: bcb's pat here...
Pushed — ac61f2f is on new-blog@v1, remote left clean, and that PAT is safe to revoke; it was used only for this push.
Workers Builds is rebuilding from it. I'll verify live once it's done: pager on the homepage and /page/2/ serving the 6th post.
Pagination's live. The homepage now shows the pager with a /page/2/ link, /page/2/ serves 测试, and /page/1/ 404s as designed.
One note if you see a red X on the commit: that's the Actions workflow failing at the DogeCloud step again — the actual deploy via Builds succeeded.
me: can u move 'Previous1 2 Next' to the right bottom of the webpage?
Done locally — the pager is now right-aligned at the bottom of the listing, on both the homepage and /page/2/. Verified in the build output, build and type check clean, committed as e192892.
One note on interpretation: I right-aligned it within the page flow at the bottom, not as a floating corner element that stays visible while scrolling. If you meant the floating kind, say so and I'll switch it.
Paste a fresh bcb PAT and I'll push it live.
me: bcb's pat here...
Pushed — e192892 is on new-blog@v1, remote left clean, and that PAT is safe to revoke now.
Workers Builds is rebuilding. I'll verify live once it's done: pager right-aligned on both the homepage and /page/2/.
It's live — the pager sits at the bottom-right on both the homepage and /page/2/, verified on the live pages.
me: can u make https://bcb.luckypoem.workers.dev/articles/ also support pagination?
Done locally — /articles/ now paginates in the same shape: 5 per page, numbered pager (right-aligned, same component), hidden on a single page. Page 1 is /articles/, page 2 is /articles/page/2/ (holding 测试), and /articles/page/1/ isn't generated, same as the homepage. Article detail routes are untouched.
Verified: build and type check clean, dist routes correct, homepage pager intact. Committed as 1d88c6b, nothing pushed yet — paste a fresh bcb PAT and I'll push it live.
me: bcb's pat here...
Pushed — 1d88c6b is on new-blog@v1, remote left clean, and that PAT is safe to revoke now.
Workers Builds is rebuilding. I'll verify live once it's done: pager on /articles/, /articles/page/2/ serving 测试, /articles/page/1/ 404ing, and a detail page intact.
Not live yet — the rebuild is still running at the 5-minute mark, so the site is still serving the previous version: /articles/ unchanged, /articles/page/2/ still 404s. Nothing's broken, it's just not deployed yet.
I'm re-checking in a few minutes and will confirm once it's up.
It's live now — the rebuild finished on the recheck. /articles/ shows the pager link, and /articles/page/2/ serves 测试.
得到的博客地址: https://bcb.luckypoem.workers.dev/
项目地址:
https://github.com/bosens-China/blog
https://github.com/brightmann/bcb
新建源帖:
首先在 https://github.com/brightmann/bcb/settings里面,启用issues.
然后访问https://github.com/brightmann/bcb/issues/,新建一个issue,添加label,比如misc.
新建一个issue后,要等待5-10分钟,博客网站才会更新。
Friday, 11 September 2026
Configuring a publishing source for your GitHub Pages site
You can configure your GitHub Pages site to publish when changes are pushed to a specific branch, or you can write a GitHub Actions workflow to publish your site.
Who can use this feature?
People with admin or maintainer permissions for a repository can configure a publishing source for a GitHub Pages site.
GitHub Pages is available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. See GitHub's plans.
In this article
About publishing sources
You can publish your site when changes are pushed to a specific branch, or you can write a GitHub Actions workflow to publish your site.
If you do not need any control over the build process for your site, we recommend that you publish your site when changes are pushed to a specific branch. You can specify which branch and folder to use as your publishing source. The source branch can be any branch in your repository, and the source folder can either be the root of the repository (/) on the source branch or a /docs folder on the source branch. Whenever changes are pushed to the source branch, the changes in the source folder will be published to your GitHub Pages site.
If you want to use a build process other than Jekyll or you do not want a dedicated branch to hold your compiled static files, we recommend that you write a GitHub Actions workflow to publish your site. GitHub provides workflow templates for common publishing scenarios to help you write your workflow.
Warning
GitHub Pages sites are publicly available on the internet, even if the repository for the site is private (if your plan or organization allows it). If you have sensitive data in your site's repository, you may want to remove the data before publishing. For more information, see About repositories.
Publishing from a branch
-
Make sure the branch you want to use as your publishing source already exists in your repository.
-
On GitHub, navigate to your site's repository.
-
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

-
In the "Code, planning, and automation" section of the sidebar, click Pages.
-
Under "Build and deployment", under "Source", select Deploy from a branch.
-
Under "Build and deployment", use the branch dropdown menu and select a publishing source.

-
Optionally, use the folder dropdown menu to select a folder for your publishing source.

-
Click Save.
Troubleshooting publishing from a branch
Note
If your repository contains symbolic links, you will need to publish your site using a GitHub Actions workflow. For more information about GitHub Actions, see GitHub Actions documentation.
Note
- If you are publishing from a branch and your site has not published automatically, make sure someone with admin permissions and a verified email address has pushed to the publishing source.
- Commits pushed by a GitHub Actions workflow that uses the
GITHUB_TOKENdo not trigger a GitHub Pages build.
If you choose the docs folder on any branch as your publishing source, then later remove the /docs folder from that branch in your repository, your site won't build and you'll get a page build error message for a missing /docs folder. For more information, see Troubleshooting Jekyll build errors for GitHub Pages sites.
Your GitHub Pages site will always be deployed with a GitHub Actions workflow run, even if you've configured your GitHub Pages site to be built using a different CI tool. Most external CI workflows "deploy" to GitHub Pages by committing the build output to the gh-pages branch of the repository, and typically include a .nojekyll file. When this happens, the GitHub Actions workflow will detect the state that the branch does not need a build step, and will execute only the steps necessary to deploy the site to GitHub Pages servers.
To find potential errors with either the build or deployment, you can check the workflow run for your GitHub Pages site by reviewing your repository's workflow runs. For more information, see Viewing workflow run history. For more information about how to re-run the workflow in case of an error, see Re-running workflows and jobs.
Publishing with a custom GitHub Actions workflow
To configure your site to publish with GitHub Actions:
-
On GitHub, navigate to your site's repository.
-
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

-
In the "Code, planning, and automation" section of the sidebar, click Pages.
-
Under "Build and deployment", under "Source", select GitHub Actions.
-
GitHub will suggest several workflow templates. If you already have a workflow to publish your site, you can skip this step. Otherwise, choose one of the options to create a GitHub Actions workflow. For more information about creating your custom workflow, see Creating a custom GitHub Actions workflow to publish your site.
GitHub Pages does not associate a specific workflow to the GitHub Pages settings. However, the GitHub Pages settings will link to the workflow run that most recently deployed your site.
Creating a custom GitHub Actions workflow to publish your site
For more information about GitHub Actions, see GitHub Actions documentation.
When you configure your site to publish with GitHub Actions, GitHub will suggest workflow templates for common publishing scenarios. The general flow of a workflow is to:
- Trigger whenever there is a push to the default branch of the repository or whenever the workflow is run manually from the Actions tab.
- Use the
actions/checkoutaction to check out the repository contents. - If required by your site, build any static site files.
- Use the
actions/upload-pages-artifactaction to upload the static files as an artifact. - If the workflow was triggered by a push to the default branch, use the
actions/deploy-pagesaction to deploy the artifact. This step is skipped if the workflow was triggered by a pull request.
The workflow templates use a deployment environment called github-pages. If your repository does not already include an environment called github-pages, the environment will be created automatically. We recommend that you add a deployment protection rule so that only the default branch can deploy to this environment. For more information, see Managing environments for deployment.
Note
A CNAME file in your repository file does not automatically add or remove a custom domain. Instead, you must configure the custom domain through your repository settings or through the API. For more information, see Managing a custom domain for your GitHub Pages site and REST API endpoints for GitHub Pages.
Troubleshooting publishing with a custom GitHub Actions workflow
For information about how to troubleshoot your GitHub Actions workflow, see Monitor workflows.
from https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site
Friday, 3 July 2026
搭建显示ip的网站程序 get-ip-info
首先fork此项目https://github.com/kanaru-ssk/get-ip-info ,我fork后,得到的项目地址为
https://github.com/brightmann/gii 。gii目录里有index.html.
点击settings(https://github.com/brightmann/gii/settings)->pages (https://github.com/brightmann/gii/settings/pages),在
Build and deployment
Tuesday, 30 June 2026
SSH 通过 443 端口连接 GitHub
GitHub 提供了两种协议供用户使用 Git 连接—— SSH 和 HTTPS。理论上我可以随意选择两者之一连接到我在 GitHub 上的代码仓库,无论是将云端的仓库 clone 到本地,还是将本地的修改 push 到云端。然而,出于一些奇奇怪怪的原因,我所在的办公网络环境禁止了 22 端口,而 22 端口正是 GitHub 提供 SSH 访问的端口号。尽管可以换用 HTTPS 协议,但无论如何将我电脑上的所有代码仓库的上游都从 git@github.com:... 修改成 https://github.com/... 仍然是一个繁重的体力活。
为了一劳永逸地解决这个问题,最理想的解决方式是让 Git 的 SSH 协议改用 22 以外的其他端口连接 GitHub。
SSH 连接失败
我们在 clone GitHub 上的代码仓库时,可以看到 GitHub 提供了两种不同的链接(以我的 SpinalHDL 模版仓库为例):
git clone https://github.com/zhutmost/spinalhdl-template.git # HTTPS
git clone git@github.com:zhutmost/spinalhdl-template.git # SSH
其中第一种方式,即 HTTPS 协议,一般总能可以工作(只要能在浏览器里打开 GitHub),而后者依赖 SSH 的正常工作。因为我的网络环境阻断了 22 端口的连接,所以我测试 GitHub 的 SSH 连接时会出现以下报错:
❯ ssh -T git@github.com
kex_exchange_identification: Connection closed by remote host
Connection closed by xx.xx.xx.xx port 22
而在理想情况下,上述命令应当输出:
❯ ssh -T git@github.com
Hi zhutmost! You've successfully authenticated, but GitHub does not provide shell access.
奇妙的冒名顶替
仔细发掘 GitHub 的文档,可以发现 GitHub 在另一个域名(ssh.github.com)上提供了一个 443 端口的 SSH 服务。显然,防火墙一般不会阻拦 443 端口(只要能浏览 GitHub 网站就能连上),可以用下面的命令进行测试:
❯ ssh -T -p 443 git@ssh.github.com
为了让Git也能通过上述端口用 SSH 访问 GitHub,我们为上述 SSH 连接方式设置一个别名。首先找到SSH的配置文件,它的路径一般是 ~/.ssh/config,如果这个文件不存在的话也可以创建一个。然后,在其中增加以下内容:
Host github.com
HostName ssh.github.com
User git
Port 443
其中,Host 是别名,HostName 是实际的域名地址,Port 是端口号。因为我希望当我在用 SSH 连接 github.com 时,实际访问的是 ssh.github.com,所以 Host 和 HostName 分别设置成这两个域名(注意不要颠倒顺序)。
如此一来,ssh.github.com 就成为了 github.com 的“冒名顶替”者。当 Git 通过 SSH 协议试图访问 github.com 的时候,SSH 会发现它是 ssh.github.com 的别名,因此会用 443 端口实际连接到后者。这样,就绕开了本地网路环境对 22 端口的限制。
(我之所以使用上述方法,是因为我的网络情况比较复杂。建议公司的朋友在使用暗渡陈仓之策前,先和 IT 部门确认下是否合规。)
from https://zhutmost.com/post/github-ssh-443
Sunday, 14 June 2026
一个短网址服务:gh-pages-url-shortener,它可以缩短任何长网址
Minimal URL shortener that can be entirely hosted on GitHub pages.
This is a minimal URL shortener that can be entirely hosted on GitHub pages. It does not need the maintenance of any servers or databases and can be hosted entirely on GitHub for free!
-
To add a new short link, add an issue with the title being the link you want to shorten (including the
http(s)://) to https://github.com/nelsontky/gh-pages-url-shortener-db/issues. -
The newly created short url can be accessed via
ccb.wtf/{issue_number}
☕️ Features
-
Unlike many URL shorteners, this one
does not need a databaseuses a "database" in the form of GitHub issues and can be entirely hosted on GitHub pages. -
There is no need for the pound symbol - short URLs look clean like this:
ccb.wtf/1instead of looking like this:ccb.wtf/#1.
💡 How does this work?
Thanks to @kidGodzilla for the pretty neat explanation here.
- 404.html handles all requests
- Small javascript snippet fetches a JSON representation of the GitHub issue via the JSON API, and redirects to the issue title, as a URL.
😎 This is so cool! How can I use this with my own domain?!
Disclaimer: This method of creating a URL shortener is hacky and not meant to be reliable. Do proceed at your own risk!
- Fork the repo before cloning your fork.
- Set up GitHub pages for your forked repo.
- If you are using your own domain:
- Set your domain up for GitHub pages.
- Change the URL in
CNAMEfile to your domain.
- If you are using GitHub page's default domain i.e. Something like
https://<username>.github.io/<repo-name>/- Delete the
CNAMEfile. - Change
var PATH_SEGMENTS_TO_SKIP = 0;at the top of404.htmltovar PATH_SEGMENTS_TO_SKIP = 1;.- This is as GitHub domains have an additional path segment (the repo name) after the host name.
- Delete the
- Create a new repo as a database. (Or you could use your forked repo)
- Update
var GITHUB_ISSUES_LINK = "<your-github-issues-link>";at the top of404.htmlaccordingly afterwards.- Format for
GITHUB_ISSUES_LINK:https://api.github.com/repos/{owner}/{repo}/issues/ - Remember the trailing
/!
- Format for
- Update
- Push your changes to your forked repo, and your low cost and cool as heck URL shortener will be ready for use!
🍴 Featured forks
To feature your fork here, edit this section and open a PR!
- eexit.github.io/s - Created a bash script that allows for shortening of URLs straight on the command line! Check out his script here.
- gh-short-url - A npm command line tool that uses GitHub pages to convert short URLs.
from https://github.com/nelsontky/gh-pages-url-shortener
( https://github.com/brightmann/url-shortener)
示例: https://github.com/nelsontky/gh-pages-url-shortener-db/issues/1894 ,
然后访问 https://ccb.wtf/1894 即可跳转到
https://www.youtube.com/watch?v=qW5_A_zUjlw
----------------------------------------------------------------
使用 GitHub 搭建自己的短链接服务
使用两个 GitHub 仓库和一个域名就能拥有免费的短链接服务。
前两天偶然在 GitHub 发现一个挺有意思的项目,可以不依赖自己的服务器、数据库来构建一个短链接服务。自己尝试了一下,还挺简单的。这里记录一下自己的构建流程,感兴趣的小伙伴可以自己尝试一下。
Prerequisites
新建两个 GitHub 仓库,一个用来做服务器存储源码、提供服务(url_shortener),一个用来做数据库存储链接(url_shortener_db)
注册一个域名(可选),如果没有的话,可以直接使用 GitHub pages 的域名(username.github.io)。
获取及配置源码
首先,你需要获取这个服务的源代码,你可以直接 fork 这个源码仓库-
https://github.com/nelsontky/gh-pages-url-shortener
然后,在你的GitHub 仓库网页(我的是https://github.com/brightmann/url-shortener)上操作,修改404.html文件的GITHUB_ISSUES_LINK字段,指向自己的url_shortener_db仓库,这个仓库的issues就是作为存储你的链接的数据库:
var GITHUB_ISSUES_LINK =
"https://api.github.com/repos/username/repo-name/issues/";
注意把上面的username repo-name替换为自己的用户名及仓库名。还有,最后的/不要漏掉,这是获取链接的关键。我的情形是
https://api.github.com/repos/brightmann/url_shortener_db/issues/
配置 GitHub Pages
接下来就是配置 Github Pages 了,这部分也很简单。
点击仓库的Settings选项,找到其中的GitHub Pages部分,然后配置Source中的分支:
下面的部分根据自己需要选择:
如果你不使用自己的域名:
删除仓库中的CNAME文件
把404.html文件中的var PATH_SEGMENTS_TO_SKIP = 0;改为var PATH_SEGMENTS_TO_SKIP = 1;
到这里就结束了。
测试效果
在你开始作为数据库的 GitHub仓库(我的是
https://github.com/brightmann/url_shortener_db)创建一个 issue,标题就是你需要缩短的某个长网址,其他什么都不需要做,直接 Submit 就行了。我在此
https://github.com/brightmann/url_shortener_db/issues/1 创建了一个issue.
等待一会儿,然后在浏览器访问:https://brightmann.github.io/url-shortener/1 ,就会跳转到https://www.youtube.com/watch?v=sNYVlOhMgIg
有人在这里-https://github.com/nelsontky/gh-pages-url-shortener/issues/5#issuecomment-728040879给了一个比较好的解释,大家可以参考一下。
参考:
https://github.com/nelsontky/gh-pages-url-shortener
Friday, 22 May 2026
ghp-import
Easily import docs to your gh-pages branch.
As part of gunicorn, Benoit Chesneau and Paul Davis were looking at how to host documentation. There's the obvious method of using GitHub's post-receive hook to trigger doc builds and rsync to a webserver, but we ended up wanting to try out github's hosting to make the whole interface a bit more robust.
GitHub Pages is a pretty awesome service that GitHub provides for
hosting project documentation. The only thing is that it requires a
gh-pages branch that is the site's document root. This means that keeping
documentation sources in the branch with code is a bit difficult. And it really
turns into a head scratcher for things like Sphinx that want to
access documentation sources and code sources at the same time.
Then we stumbled across an interesting looking package called
github-tools that looked almost like what we wanted. It was a tad
complicated and more involved than we wanted but it gave us an idea. Why not
just write a script that can copy a directory to the gh-pages branch of the
repository. This saves us from even having to think about the branch and
everything becomes magical.
This is what ghp-import was written for.
This will DESTROY your gh-pages branch. If you love it, you'll want to
take backups before playing with this. This script assumes that gh-pages is
100% derivative. You should never edit files in your gh-pages branch by hand
if you're using this script because you will lose your work.
When used with a prefix, only files below the set prefix will be destroyed, limiting the above warning to just that directory and everything below it.
Usage: ghp-import [OPTIONS] DIRECTORY
Options:
-n, --no-jekyll Include a .nojekyll file in the branch.
-c CNAME, --cname=CNAME
Write a CNAME file with the given CNAME.
-m MESG, --message=MESG
The commit message to use on the target branch.
-p, --push Push the branch to origin/{branch} after committing.
-x PREFIX, --prefix=PREFIX
The prefix to add to each file that gets pushed to the
remote. Only files below this prefix will be cleared
out. [none]
-f, --force Force the push to the repository.
-o, --no-history Force new commit without parent history.
-r REMOTE, --remote=REMOTE
The name of the remote to push to. [origin]
-b BRANCH, --branch=BRANCH
Name of the branch to write to. [gh-pages]
-s, --shell Use the shell when invoking Git. [False]
-l, --follow-links Follow symlinks when adding files. [False]
-h, --help show this help message and exit
Its pretty simple. Inside your repository just run ghp-import $DOCS_DIR
where $DOCS_DIR is the path to the built documentation. This will write a
commit to your gh-pages branch with the current documents in it.
If you specify -p it will also attempt to push the gh-pages branch to
GitHub. By default it'll just run git push origin gh-pages. You can specify
a different remote using the -r flag.
The -o option will discard any previous history and ensure that only a
single commit is always pushed to the gh-pages branch. This is useful to
avoid bloating the repository size and is highly recommended.
You can specify a different branch with -b. This is useful for user and
organization page, which are served from the master branch.
Some Windows users report needing to pass Git commands through the shell which can be accomplished by passing -s.
The -l option will cause the import to follow
symlinks for users that have odd configurations that include symlinking
outside of their documentation directory.
You can also call ghp_import directly from your Python code as a library. The
library has one public function ghp_import.ghp_import, which accepts the
following arguments:
srcdir: The path to the built documentation (required).remote: The name of the remote to push to. Default:origin.branch: Name of the branch to write to. Default:gh-pages.mesg: The commit message to use on the target branch. Default:Update documentation.push: Push the branch to {remote}/{branch} after committing. Default:False.prefix: The prefix to add to each file that gets pushed to the remote. Default:None.force: Force the push to the repository. Default:False.no_history: Force new commit without parent history. Default:False.use_shell: Default: Use the shell when invoking Git.False.followlinks: Follow symlinks when adding files. Default:False.cname: Write a CNAME file with the given CNAME. Default:None.nojekyll: Include a .nojekyll file in the branch. Default:False.
from https://github.com/c-w/ghp-import
( https://docs.getpelican.com/zh-cn/latest/tips.html)
如何push静态网站的根目录到your-username.github.io/abc?
此问题困扰了我多年,今天无意中看到https://github.com/briteming/vuepress-web-app/blob/master/deploy.sh ,得到了启发。
以静态博客程序zola( https://briteming.blogspot.com/2020/03/rust-zola.html)为例。
我在windows机器上,安装了git-bash,然后安装了rust环境。按此文 https://briteming.blogspot.com/2020/03/rust-zola.html生成静态网站的根目录-public目录。
因为下面要把静态网站的根目录-public目录push到your-username.github.io/abc ,所以要编辑~/zola-site/config.toml文件,把base_url的值设为"/zola"
cd public
(此处的public为静态网站的根目录)
$ git init .
$ git add .
$ git commit -m 'xx'
$ git remote add origin git@github-second:briteming/zola
$ git push -f git@github-second:briteming/zola master:gh-pages
显示:
。。。
master -> gh-pages (forced update)
就表明push成功。然后访问briteming.github.io/zola即可看到网站效果。
注意:如果你有多个github帐号要做切换,请先阅读https://briteming.blogspot.com/2012/04/githubssh-key.html
你的仓库github.com/your-username/abc需要先被创建:
访问 https://github.com/your-username?tab=repositories, 然后访问https://github.com/new,创建空白仓库abc.
翻墙后不学GitHub等于白翻,从零开始带你玩转开发者天堂
https://github.com/explore
https://github.com/topics
https://github.com/trending
https://github.com/collections
Sunday, 17 May 2026
cloudflare-worker-github-oauth-login
Use a Cloudflare worker for GitHub's OAuth login flow。
A Cloudflare Worker + GitHub Pages Login Example
The github-oauth-login.js file is a Cloudflare Worker which is continuously deployed using GitHub Actions (see .github/workflows/deploy.yml).
The worker does 3 things
- When you open the worker URL, it will redirect to the OAuth App's login URL on github.com (example).
- It accepts a
POSTrequest with the OAuthcoderetrieved from the OAuth callback redirect and returns an OAuth access token in return - It enables CORS.
The index.html file is a demo of a "Login with GitHub" app, you can see the demo at gr2m.github.io/cloudflare-worker-github-oauth-login/index.html. Look at its source code. If something is unclear, please feel free to open an issue or ping me on twitter.
Note that you require access to the new GitHub Actions for the automated deployment to work.
-
Fork this repository
-
Create a Cloudflare account (it's free!) if you don't have one yet.
-
Install the
wranglerCLI and login with your accountnpm install --global wrangler wrangler login -
Edit the
wrangler.tomlfile, change the value foraccount_idto your own (select your account, then find your Account ID at the bottom of the side bar) -
Add the following secrets to your Cloudflare worker:
-
CLIENT_ID,CLIENT_SECRET: In your GitHub (OAuth) App's settings page, findClient IDandClient SECRETwrangler secret put CLIENT_ID wrangler secret put CLIENT_SECRET
-
-
Add the following secret in your fork's repository settings:
CF_API_TOKEN: Create a new token, use the "Edit Cloudflare Workers" template
-
Enable GitHub Pages in your repository settings, select
Sourceto be themaster branch. -
In index.html, replace the
gr2mworkers subdomain with your own, inWORKER_URLand the login<a href="...">tag.
That should be it. The github-oauth-login.js file will now be continously deployed to Cloudflare each time there is a commit to master.
The OAuth App Avatar and this repository's social preview are using @cameronmcefee's cloud Octodex graphic。
from https://github.com/gr2m/cloudflare-worker-github-oauth-login
Saturday, 28 March 2026
GitHub Desktop
Git can be intimidating, this app makes interactions with Git easier.
https://desktop.github.com/download/







