首页 > 解决方案 > github页面字体和index.html不起作用

问题描述

我在我的博客 alireza.one 的 github 上创建了一个 repo,现在我想创建一个波斯博客,我有两个问题:

第一:字体不加载。我在我的 css 上放了一条导入行,但它没有加载。

@import url('https://alireza.one/farsi/assets/type.css');

我的波斯语(波斯语)博客加载了我的主 CSS,但没有加载字体。我的存储库:alirezahy/farsi。我的网页:alireza.one/farsi

第二:我的 index.html(在波斯语 repo 和 alirezahy.github.io 中)是这样的:

---
layout: default
title: Index
---


<div class="listing">
    {% for post in paginator.posts %}
    <div class="post other link">
      <h2></span> <a href="{{site.url}}{{post.url}}">{{ post.title }}</a></h2>
      <p class="post-date">{{ post.date | date_to_string }}</p>
    </div>
    {% endfor %}
</div>

我怎样才能使它成为一个正常的 index.html 以便我的首页看起来像一个正常的博客而不是一个站点页面。

标签: htmlcssfont-facegithub-pages

解决方案


如果要添加字体,则需要在 css 文件中像这样添加它:

@font-face {
font-family: "myFont";
src: url(fontofallknowledge.woff);
}

然后你可以像这样使用字体

body{
font-family: "myFont";
}

您将使用 @import 来导入样式表。

要回答您的第二个问题,您似乎在 .html 文件中使用了 php。你不可以做这个。


推荐阅读