Github零成本部署网站

网站的意义

网站是互联网上的信息平台,用于发布和交流内容。它们提供了从教育资料到商业服务等各种信息和服务。对企业和个人而言,网站是展示形象、沟通用户的重要渠道,有助于提升品牌认知度和促进业务发展。随着移动技术的进步,网站也成为了人们获取信息和进行互动的主要途径之一。


但是,自己部署网站要么买云服务器要么买公网IP(当然你也可以使用运营商分配的公网IPV6,不过较为麻烦)才能让别人在公网上访问你的网站。

不过以上方法都要花钱,那该怎么办呢?

答:使用免费的Github Pages服务。

教程

1.注册GitHub账号

打开https://github.com/ 输入你的邮箱 并点击 sign up for github
点击continue 输入密码(大小写字母、数字、符号)再点击continue
输入用户名(英文、数字)并点击continue
勾选此处 并点击continue
通过人机验证
打开邮箱 复制验证码
粘贴至GitHub
登录GITHUB
创建仓库(选择Public 仓库名填你的用户名+"github.io")
添加文件
添加HTML内容(文件名填"index.html")并点击绿色按钮提交
html 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>XXXX</title>
    <style>
        /* Reset some default browser styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            background-color: #f0f8ff; /* Light blue background */
            color: #333;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        header {
            background-color: #fff;
            padding: 10px 20px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-radius: 5px;
        }

        nav ul {
            list-style-type: none;
            display: flex;
        }

        nav ul li {
            margin-left: 20px;
        }

        nav ul li a {
            text-decoration: none;
            color: #007bff; /* Blue links */
            transition: all 0.3s ease;
        }

        nav ul li a:hover {
            transform: scale(1.1); /* Button hover effect */
        }

        .hero {
            background-color: #fff;
            padding: 50px;
            margin-top: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .hero img {
            width: 100%;
            height: auto;
            max-width: 500px;
            margin-bottom: 20px;
        }

        .exhibitions {
            background-color: #fff;
            padding: 50px;
            margin-top: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .footer {
            background-color: #fff;
            padding: 20px;
            margin-top: 20px;
            text-align: center;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .footer p {
            margin: 5px 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>XXXX</h1>
            <nav>
                <ul>
                    <li><a href="#home">首页</a></li>
                    <li><a href="#about">关于我们</a></li>
                    <li><a href="#services">服务</a></li>
                    <li><a href="#contact">联系我们</a></li>
                </ul>
            </nav>
        </header>

        <section class="hero">
            <img src="https://via.placeholder.com/500x300" alt="Hero Image">
            <p>欢迎来到我们的官方网站!</p>
        </section>

        <section class="exhibitions">
            <h2>展览信息</h2>
            <p>这里是我们即将举行的展览详情。</p>
        </section>

        <footer class="footer">
            <p>版权所有 © 2024 XXXXXXXXX 保留所有权利</p>
            <p>ICP备案号: 浙ICP备291023号</p>
        </footer>
    </div>

    <script>
        // Add button hover effect using jQuery (make sure to include jQuery in your actual project)
        $(document).ready(function() {
            $('nav ul li a').hover(function() {
                $(this).stop().animate({ transform: 'scale(1.1)' }, 200);
            }, function() {
                $(this).stop().animate({ transform: 'scale(1)' }, 200);
            });
        });
    </script>
</body>
</html>
配置PAGES服务

进入SETTINGS选项 并设置成图片中那样 点击save

网站上线

等待1分钟左右,记得没过一会儿刷新以下,直到出现类似于一下图片的样子

点击网址连接即可访问

相关推荐
镜宇秋霖丶6 分钟前
2026.5.6@霖宇博客制作中遇见的问题
前端·javascript·vue.js
Raytheon_code8 分钟前
从零到一:我用微信小程序做了一款串珠DIY定制工具
css·微信小程序·html5·ai编程
yyuuuzz1 小时前
aws亚马逊入门常见认知误区
运维·服务器·网络·云计算·github·aws
小李子呢02111 小时前
前端八股Vue---Vue-router路由管理器
前端·javascript·vue.js
洛_尘3 小时前
Python 5:使用库
java·前端·python
Bigger3 小时前
Bun 能上生产吗?我的实战结论
前端·node.js·bun
kyriewen4 小时前
你的前端滤镜慢得像PPT?用Rust+WebAssembly,一秒处理4K图
前端·rust·webassembly
kyriewen115 小时前
你等的Babel编译,够喝三杯咖啡了——用Rust重写的SWC,只需眨个眼
开发语言·前端·javascript·后端·性能优化·rust·前端框架
IT_陈寒5 小时前
SpringBoot自动配置坑了我,原来要这样绕过去
前端·人工智能·后端
东方小月5 小时前
Claude Code 完整上手指南:MCP、Skills、第三方模型配置一次搞定
前端·人工智能·后端