linkcheck는 HTML 및 CSS 파일 내 링크의 무결성을 검증하는 고성능 도구입니다. 웹사이트를 효율적으로 크롤링하여 손상되거나 접근할 수 없는 링크를 식별하여 콘텐츠 신뢰성을 보장합니다. 개발자와 사이트 관리자를 위해 설계되었으며, 안드로이드, iOS, macOS, Windows, 리눅스 등 여러 플랫폼을 지원합니다. Flutter의 pub 시스템을 통해 개발 워크플로우에 원활하게 통합됩니다. 빠른 스캔 기능으로 정기적인 사이트 감사 및 품질 보증 프로세스에 이상적입니다.
사용 사례
웹사이트 유지보수
자동 링크 검증
배포 전 점검
콘텐츠 무결성 검증
CI/CD 파이프라인 통합
주요 기능
빠른 크롤링 성능
HTML 및 CSS 링크 탐지 지원
크로스 플랫폼 호환성
명령줄 인터페이스
Flutter 프로젝트와의 통합
적합한 대상
프론트엔드 개발자
사이트 관리자
데브옵스 엔지니어
품질 보증 팀
콘텐츠 관리자
고려 사항
외부 링크 확인을 위해 인터넷 연결이 필요합니다
동적 콘텐츠와 함께 잘못된 긍정 결과를 생성할 수 있습니다
실시간 모니터링을 위한 설계가 아님
링크의 정적 분석에 제한됨
외부 사이트에는 레이트 제한이 적용될 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
linkcheck
Very fast link-checking.
Philosophy:
A good utility is custom-made for a job. There are many link checkers out there,
but none of them seems to be striving for the following set of goals.
Crawls fast
You want to run the link-checker at least before every deploy (on CI
or manually). When it takes ages, you're less likely to do so.
linkcheck is currently several times faster than
blc and all other link
checkers that go to at least comparable depth. It is 40 times faster than the
only tool that goes to the same depth
(linkchecker).
Finds all relevant problems
No link-checker can guarantee correct results: the web is too flaky
for that. But at least the tool should correctly parse the HTML (not just
try to guess what's a URL and what isn't) and
the CSS (for url(...) links).
PENDING: srcset support
linkcheck finds more than linklint and
blc. It finds the
same amount or more problems than the best alternative,
linkchecker.
Leaves out irrelevant problems
linkcheck doesn't attempt to render JavaScript. It would make
it at least an order of magnitude slower and way more complex. (For example,
what links and buttons should the tool attempt to click, and how many
times? Should we only click visible links? How exactly do we detect broken
links?) Validating SPAs is a very different problem than checking static
links, and should be approached by dedicated tools.
linkcheck only supports http: and https:. It won't try to check
FTP or telnet or nntp links.
Note: linkcheck will currently completely ignore unsupported schemes
like ftp: or mailto: or data:. This may change in the future to
at least show info-level warning.
linkcheck doesn't validate file system directories. Servers often behave
very differently than file systems, so validating links on the file system
often leads to both false positives and false negatives. Links should be
checked in their natural habitat, and as close to the production environment
as possible. You can (and should) run linkcheck on your localhost server,
of course.
Good UX
Yes, a command line utility can have good or bad UX. It has mostly to do with
giving sane defaults, not forcing users to learn new constructs, not making
them type more than needed, and showing concise output.
The most frequent use cases should be only a few arguments.
For example, unleashing linkcheck on http://localhost:4001/ can be done
via linkcheck :4001.
linkcheck doesn't throttle itself on localhost.
linkcheck follows POSIX CLI standards (no @input and similar constructs
like in linklint).
Brief and meaningful output
When everything works, you don't want to see a huge list of links.
In this scenario, linkcheck just outputs 'Perfect' and some stats on
a single line.
When things are broken, you want to see where exactly is the problem
and you want to have it sorted in a sane way.
linkcheck lists broken links by their source URL first so that you can
fix many links at once. It also sorts the URLs alphabetically, and shows
both the exact location of the link (line:column) and the anchor
text (or the tag if it wasn't an anchor).
For CI builds, you want non-zero
exit code whenever there is a problem.
linkcheck returns status code 1 if there are warnings, and
status code 2 if there are errors.
It goes without saying that linkcheck fully respects definitions
in robots.txt and throttles itself when accessing websites.
Installation
Direct download
Download the latest executable from the
Releases page on GitHub.
Pick the executable for your system (for example, linkcheck-win-x64.exe for
a 64-bit machine running Microsoft Windows).
You should be able to immediately run this executable -- it has no external
dependencies. For example, assuming you are on macOS and downloaded the file
to the default downloads directory, you can go to your Terminal
(or iTerm, or SSH) and run ./Downloads/linkcheck-mac-x64.
You can rename the file and move it to any directory. For example,
on a Linux box, you might want to rename the executable to simply
linkcheck, and move it to /usr/local/bin, $HOME/bin or another
directory in your $PATH.
Follow the installation instructions for your platform
from the Get the Dart SDK documentation.
For example, on a Mac, assuming you have homebrew,
you just run:
$ brew tap dart-lang/dart
$ brew install dart
Step 2. Install linkcheck
Once Dart is installed, run:
$ dart pub global activate linkcheck
Pub installs executables into ~/.pub-cache/bin, which may not be on your path.
You can fix that by adding the following to your shell's config file (.bashrc,
.bash_profile, etc.):
export PATH="$PATH":"~/.pub-cache/bin"
Then either restart the terminal or run source ~/.bash_profile (assuming
~/.bash_profile is where you put the PATH export above).
Docker
If you have Docker installed, you can build the image and use the container
avoiding local Dart installation.
Build
In the project directory, for x86 and x64 architectures, run
You probably want to make sure you never break your inbound links. For example,
if a page changes URL, the previous URL should still work (redirecting to the
new page when appropriate).
Where do you get a list of inbound links? Try your site's sitemap.xml as
a starting point, and — additionally — try something like the Google Webmaster
Tools’ crawl error page.
Skipping URLs
Sometimes, it is legitimate to ignore some failing URLs. This is done via
the --skip-file option.
Let's say you're working on a site and a significant portion of it is currently
under construction. You can create a file called my_skip_file.txt, for
example, and fill it with regular expressions like so:
# Lines starting with a hash are comments.
admin/
\.s?css$
\#info
The file above includes a comment on line 1 which will be ignored. Line 2 is
blank and will be ignored as well. Line 3 contains a broad regular expression
that will make linkcheck ignore any link to a URL containing admin/
anywhere in it. Line 4 shows that there is full support for
regular expressions – it will ignore URLs ending with .css and
.scss. Line 5 shows the only special escape sequence.
If you need to start your regular expression with a #
(which linkcheck would normally parse as a comment) you can
precede the # with a backslash (\). This will force linkcheck
not to ignore the line. In this case, the regular expression on line 4
will match #info anywhere in the URL.
Regular expressions are hard. If unsure, use the -d option to see what URLs
your skip file is ignoring, exactly.
To use a skipfile while running linkchecker through docker create a directory
to use as a volume in docker and put your skip file in it. Then use a command
similar to the following (assuming the folder was named skipfiles):
docker run -v "$(pwd)/skipfiles/:/skipfiles/" filiph/linkcheck http://example.com/ --skip-file /skipfiles/skipfile.txt
User agent
The tool identifies itself to servers with the following user agent string:
Commit all your changes, including updates to CHANGELOG,
and including updating the version number in pubspec.yaml
and lib/linkcheck.dart. Let's say your new version number is 3.4.56.
That number should be reflected in all three files.
Tag the last commit with the same version number.
In our case, it would be 3.4.56.
Push to master.
This will run the GitHub Actions script in .github/workflows/release.yml,
building binaries and placing a new release into
github.com/filiph/linkcheck/releases.
In order to populate it to the GitHub Actions Marketplace
as well, it's currently required to manually Edit and hit
Update release on the release page once. No changes needed.
(Source: GitHub Community)